or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

client-operations.mdiam-security.mdindex.mdqueue-configuration.mdqueue-management.mdtask-management.mdtask-targeting.md

queue-management.mddocs/

0

# Queue Management

1

2

Comprehensive queue lifecycle management including creation, configuration, monitoring, and control operations. Queues serve as containers for tasks with configurable rate limits, retry policies, and routing rules.

3

4

## Capabilities

5

6

### Queue Listing

7

8

Retrieve queues within a location with optional filtering and pagination support.

9

10

```python { .api }

11

def list_queues(

12

self,

13

request: Union[ListQueuesRequest, dict] = None,

14

*,

15

parent: str = None,

16

retry: OptionalRetry = DEFAULT,

17

timeout: float = DEFAULT,

18

metadata: Sequence[Tuple[str, str]] = ()

19

) -> pagers.ListQueuesPager:

20

"""List the queues in a location.

21

22

Args:

23

request: The request object or dictionary.

24

parent: Required. The location name (projects/PROJECT_ID/locations/LOCATION_ID).

25

retry: Designation of what errors should be retried.

26

timeout: The timeout for this request.

27

metadata: Strings which should be sent along with the request as metadata.

28

29

Returns:

30

An iterable of Queue resources.

31

"""

32

```

33

34

### Queue Retrieval

35

36

Get detailed information about a specific queue.

37

38

```python { .api }

39

def get_queue(

40

self,

41

request: Union[GetQueueRequest, dict] = None,

42

*,

43

name: str = None,

44

retry: OptionalRetry = DEFAULT,

45

timeout: float = DEFAULT,

46

metadata: Sequence[Tuple[str, str]] = ()

47

) -> Queue:

48

"""Get a queue.

49

50

Args:

51

request: The request object or dictionary.

52

name: Required. The resource name of the queue.

53

retry: Designation of what errors should be retried.

54

timeout: The timeout for this request.

55

metadata: Strings which should be sent along with the request as metadata.

56

57

Returns:

58

The queue object.

59

"""

60

```

61

62

### Queue Creation

63

64

Create new queues with optional configuration for rate limits, retry policies, and routing.

65

66

```python { .api }

67

def create_queue(

68

self,

69

request: Union[CreateQueueRequest, dict] = None,

70

*,

71

parent: str = None,

72

queue: Queue = None,

73

retry: OptionalRetry = DEFAULT,

74

timeout: float = DEFAULT,

75

metadata: Sequence[Tuple[str, str]] = ()

76

) -> Queue:

77

"""Create a queue.

78

79

Args:

80

request: The request object or dictionary.

81

parent: Required. The location where the queue will be created.

82

queue: Required. The queue to create.

83

retry: Designation of what errors should be retried.

84

timeout: The timeout for this request.

85

metadata: Strings which should be sent along with the request as metadata.

86

87

Returns:

88

The created queue.

89

"""

90

```

91

92

### Queue Updates

93

94

Modify existing queue configuration including rate limits, retry settings, and routing rules.

95

96

```python { .api }

97

def update_queue(

98

self,

99

request: Union[UpdateQueueRequest, dict] = None,

100

*,

101

queue: Queue = None,

102

update_mask: field_mask_pb2.FieldMask = None,

103

retry: OptionalRetry = DEFAULT,

104

timeout: float = DEFAULT,

105

metadata: Sequence[Tuple[str, str]] = ()

106

) -> Queue:

107

"""Update a queue.

108

109

Args:

110

request: The request object or dictionary.

111

queue: Required. The queue to update.

112

update_mask: A mask specifying which fields to update.

113

retry: Designation of what errors should be retried.

114

timeout: The timeout for this request.

115

metadata: Strings which should be sent along with the request as metadata.

116

117

Returns:

118

The updated queue.

119

"""

120

```

121

122

### Queue Deletion

123

124

Permanently remove queues and all contained tasks.

125

126

```python { .api }

127

def delete_queue(

128

self,

129

request: Union[DeleteQueueRequest, dict] = None,

130

*,

131

name: str = None,

132

retry: OptionalRetry = DEFAULT,

133

timeout: float = DEFAULT,

134

metadata: Sequence[Tuple[str, str]] = ()

135

) -> None:

136

"""Delete a queue.

137

138

Args:

139

request: The request object or dictionary.

140

name: Required. The queue name to delete.

141

retry: Designation of what errors should be retried.

142

timeout: The timeout for this request.

143

metadata: Strings which should be sent along with the request as metadata.

144

"""

145

```

146

147

### Queue Control Operations

148

149

Pause, resume, and purge queue operations for maintenance and task management.

150

151

```python { .api }

152

def pause_queue(

153

self,

154

request: Union[PauseQueueRequest, dict] = None,

155

*,

156

name: str = None,

157

retry: OptionalRetry = DEFAULT,

158

timeout: float = DEFAULT,

159

metadata: Sequence[Tuple[str, str]] = ()

160

) -> Queue:

161

"""Pause a queue. Tasks are not dispatched while paused.

162

163

Args:

164

request: The request object or dictionary.

165

name: Required. The queue name to pause.

166

retry: Designation of what errors should be retried.

167

timeout: The timeout for this request.

168

metadata: Strings which should be sent along with the request as metadata.

169

170

Returns:

171

The paused queue.

172

"""

173

174

def resume_queue(

175

self,

176

request: Union[ResumeQueueRequest, dict] = None,

177

*,

178

name: str = None,

179

retry: OptionalRetry = DEFAULT,

180

timeout: float = DEFAULT,

181

metadata: Sequence[Tuple[str, str]] = ()

182

) -> Queue:

183

"""Resume a paused queue. Tasks can be dispatched again.

184

185

Args:

186

request: The request object or dictionary.

187

name: Required. The queue name to resume.

188

retry: Designation of what errors should be retried.

189

timeout: The timeout for this request.

190

metadata: Strings which should be sent along with the request as metadata.

191

192

Returns:

193

The resumed queue.

194

"""

195

196

def purge_queue(

197

self,

198

request: Union[PurgeQueueRequest, dict] = None,

199

*,

200

name: str = None,

201

retry: OptionalRetry = DEFAULT,

202

timeout: float = DEFAULT,

203

metadata: Sequence[Tuple[str, str]] = ()

204

) -> Queue:

205

"""Purge all tasks from a queue. This deletes all tasks.

206

207

Args:

208

request: The request object or dictionary.

209

name: Required. The queue name to purge.

210

retry: Designation of what errors should be retried.

211

timeout: The timeout for this request.

212

metadata: Strings which should be sent along with the request as metadata.

213

214

Returns:

215

The purged queue.

216

"""

217

```

218

219

## Request Types

220

221

### ListQueuesRequest

222

```python { .api }

223

class ListQueuesRequest:

224

parent: str # Required. The location name

225

filter: str # Optional. Filter for queues

226

page_size: int # Maximum page size (max 9800)

227

page_token: str # Token for pagination

228

```

229

230

### GetQueueRequest

231

```python { .api }

232

class GetQueueRequest:

233

name: str # Required. The resource name of the queue

234

```

235

236

### CreateQueueRequest

237

```python { .api }

238

class CreateQueueRequest:

239

parent: str # Required. The location where queue will be created

240

queue: Queue # Required. The queue to create

241

```

242

243

### UpdateQueueRequest

244

```python { .api }

245

class UpdateQueueRequest:

246

queue: Queue # Required. The queue to update

247

update_mask: field_mask_pb2.FieldMask # Mask specifying fields to update

248

```

249

250

### DeleteQueueRequest

251

```python { .api }

252

class DeleteQueueRequest:

253

name: str # Required. The queue name to delete

254

```

255

256

### PauseQueueRequest

257

```python { .api }

258

class PauseQueueRequest:

259

name: str # Required. The queue name to pause

260

```

261

262

### ResumeQueueRequest

263

```python { .api }

264

class ResumeQueueRequest:

265

name: str # Required. The queue name to resume

266

```

267

268

### PurgeQueueRequest

269

```python { .api }

270

class PurgeQueueRequest:

271

name: str # Required. The queue name to purge

272

```

273

274

### ListQueuesResponse

275

```python { .api }

276

class ListQueuesResponse:

277

queues: MutableSequence[Queue] # List of queues

278

next_page_token: str # Token for next page

279

```

280

281

## Usage Examples

282

283

### Creating and Managing Queues

284

285

```python

286

from google.cloud import tasks

287

from google.protobuf import duration_pb2

288

289

client = tasks.CloudTasksClient()

290

291

# Define paths

292

project = 'my-project-id'

293

location = 'us-central1'

294

queue_name = 'my-queue'

295

296

parent = client.common_location_path(project, location)

297

queue_path = client.queue_path(project, location, queue_name)

298

299

# Create a queue with rate limits and retry config

300

queue = tasks.Queue(

301

name=queue_path,

302

rate_limits=tasks.RateLimits(

303

max_dispatches_per_second=10.0,

304

max_concurrent_dispatches=5

305

),

306

retry_config=tasks.RetryConfig(

307

max_attempts=3,

308

max_retry_duration=duration_pb2.Duration(seconds=600),

309

min_backoff=duration_pb2.Duration(seconds=1),

310

max_backoff=duration_pb2.Duration(seconds=60)

311

)

312

)

313

314

created_queue = client.create_queue(parent=parent, queue=queue)

315

print(f'Created queue: {created_queue.name}')

316

317

# Get queue details

318

retrieved_queue = client.get_queue(name=queue_path)

319

print(f'Queue state: {retrieved_queue.state}')

320

321

# Pause the queue

322

paused_queue = client.pause_queue(name=queue_path)

323

print(f'Queue paused: {paused_queue.state == tasks.Queue.State.PAUSED}')

324

325

# Resume the queue

326

resumed_queue = client.resume_queue(name=queue_path)

327

print(f'Queue resumed: {resumed_queue.state == tasks.Queue.State.RUNNING}')

328

```

329

330

### Listing and Filtering Queues

331

332

```python

333

from google.cloud import tasks

334

335

client = tasks.CloudTasksClient()

336

parent = client.common_location_path('my-project-id', 'us-central1')

337

338

# List all queues

339

for queue in client.list_queues(parent=parent):

340

print(f'Queue: {queue.name}, State: {queue.state}')

341

342

# List with filtering (if supported)

343

filtered_queues = client.list_queues(

344

parent=parent,

345

filter='state=RUNNING'

346

)

347

for queue in filtered_queues:

348

print(f'Running queue: {queue.name}')

349

350

# List with pagination

351

page_result = client.list_queues(parent=parent, page_size=10)

352

for queue in page_result:

353

print(f'Queue: {queue.name}')

354

```

355

356

### Updating Queue Configuration

357

358

```python

359

from google.cloud import tasks

360

from google.protobuf import field_mask_pb2

361

362

client = tasks.CloudTasksClient()

363

queue_path = client.queue_path('my-project-id', 'us-central1', 'my-queue')

364

365

# Get current queue

366

current_queue = client.get_queue(name=queue_path)

367

368

# Update rate limits

369

current_queue.rate_limits.max_dispatches_per_second = 20.0

370

current_queue.rate_limits.max_concurrent_dispatches = 10

371

372

# Specify which fields to update

373

update_mask = field_mask_pb2.FieldMask(

374

paths=['rate_limits.max_dispatches_per_second', 'rate_limits.max_concurrent_dispatches']

375

)

376

377

updated_queue = client.update_queue(queue=current_queue, update_mask=update_mask)

378

print(f'Updated queue rate limits: {updated_queue.rate_limits.max_dispatches_per_second}')

379

```