forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
0053.yml
646 lines (634 loc) · 26 KB
/
0053.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
version: 53
description: Use task_queue_id instead of provisioner_id / worker_type in queues
migrationScript: |-
begin
lock table queue_worker_types;
alter table queue_worker_types drop constraint queue_worker_types_pkey;
alter table queue_worker_types rename to task_queues;
alter table task_queues add column task_queue_id text;
update task_queues set task_queue_id = provisioner_id || '/' || worker_type;
alter table task_queues drop column provisioner_id, drop column worker_type;
alter table task_queues alter column task_queue_id set not null;
alter table task_queues add primary key (task_queue_id);
lock table queue_workers;
alter table queue_workers drop constraint queue_workers_pkey;
alter table queue_workers add column task_queue_id text;
update queue_workers set task_queue_id = provisioner_id || '/' || worker_type;
alter table queue_workers drop column provisioner_id, drop column worker_type;
alter table queue_workers alter column task_queue_id set not null;
alter table queue_workers add primary key (task_queue_id, worker_group, worker_id);
lock table queue_provisioners;
revoke select, insert, update, delete on queue_provisioners from $db_user_prefix$_queue;
drop table queue_provisioners;
end
downgradeScript: |-
begin
lock table task_queues;
alter table task_queues drop constraint task_queues_pkey;
alter table task_queues add column provisioner_id text, add column worker_type text;
update task_queues
set
provisioner_id = split_part(task_queues.task_queue_id, '/', 1),
worker_type = split_part(task_queues.task_queue_id, '/', 2);
alter table task_queues drop column task_queue_id;
alter table task_queues alter column provisioner_id set not null;
alter table task_queues alter column worker_type set not null;
alter table task_queues add primary key (provisioner_id, worker_type);
alter table task_queues rename to queue_worker_types;
lock table queue_workers;
alter table queue_workers drop constraint queue_workers_pkey;
alter table queue_workers add column provisioner_id text, add column worker_type text;
update queue_workers
set
provisioner_id = split_part(queue_workers.task_queue_id, '/', 1),
worker_type = split_part(queue_workers.task_queue_id, '/', 2);
alter table queue_workers drop column task_queue_id;
alter table queue_workers alter column provisioner_id set not null;
alter table queue_workers alter column worker_type set not null;
alter table queue_workers add primary key (provisioner_id, worker_type, worker_group, worker_id);
create table queue_provisioners
as
select
provisioner_id,
max(expires) as expires,
max(last_date_active) as last_date_active,
'' as description,
'experimental' as stability,
'[]'::jsonb as actions
from queue_worker_types
group by provisioner_id;
alter table queue_provisioners add primary key (provisioner_id);
alter table queue_provisioners
alter column provisioner_id set not null,
alter column expires set not null,
alter column last_date_active set not null,
alter column description set not null,
alter column stability set not null,
alter column actions set not null;
grant select, insert, update, delete on queue_provisioners to $db_user_prefix$_queue;
end
methods:
create_queue_worker_type:
description: |-
Create a new queue worker type. Raises UNIQUE_VIOLATION if the worker type already exists.
deprecated: true
mode: write
serviceName: queue
args: provisioner_id_in text, worker_type_in text, expires_in timestamptz, last_date_active_in timestamptz, description_in text, stability_in text
returns: uuid
body: |-
begin
insert
into task_queues (task_queue_id, expires, last_date_active, description, stability)
values (
provisioner_id_in || '/' || worker_type_in,
expires_in,
last_date_active_in,
description_in, stability_in
);
return public.gen_random_uuid();
end
get_queue_worker_type:
description: |-
Get a non-expired queue worker type by provisioner_id and worker_type.
deprecated: true
mode: read
serviceName: queue
args: provisioner_id_in text, worker_type_in text, expires_in timestamptz
returns: table(provisioner_id text, worker_type text, expires timestamptz, last_date_active timestamptz, description text, stability text, etag uuid)
body: |-
begin
return query
select
split_part(task_queues.task_queue_id, '/', 1) as provisioner_id,
split_part(task_queues.task_queue_id, '/', 2) as worker_type,
task_queues.expires,
task_queues.last_date_active,
task_queues.description,
task_queues.stability,
public.gen_random_uuid()
from task_queues
where
task_queues.task_queue_id = provisioner_id_in || '/' || worker_type_in and
task_queues.expires > expires_in;
end
update_queue_worker_type:
serviceName: queue
description: |-
Update a queue worker type's expires, last_date_active, description, and stability.
All parameters must be supplied.
deprecated: true
mode: write
args: provisioner_id_in text, worker_type_in text, expires_in timestamptz, last_date_active_in timestamptz, description_in text, stability_in text
returns: table(provisioner_id text, worker_type text, expires timestamptz, last_date_active timestamptz, description text, stability text, etag uuid)
body: |-
begin
return query update task_queues
set
expires = expires_in,
last_date_active = last_date_active_in,
description = description_in,
stability = stability_in
where
task_queues.task_queue_id = provisioner_id_in || '/' || worker_type_in
returning
split_part(task_queues.task_queue_id, '/', 1) as provisioner_id,
split_part(task_queues.task_queue_id, '/', 2) as worker_type,
task_queues.expires,
task_queues.last_date_active,
task_queues.description,
task_queues.stability,
public.gen_random_uuid();
end
get_queue_worker_types:
description: |-
Get queue worker types ordered by `provisioner_id` and `worker_type`.
If the pagination arguments are both NULL, all rows are returned.
Otherwise, page_size rows are returned at offset page_offset.
deprecated: true
mode: read
serviceName: queue
args: provisioner_id_in text, worker_type_in text, expires_in timestamptz, page_size_in integer, page_offset_in integer
returns: table(provisioner_id text, worker_type text, expires timestamptz, last_date_active timestamptz, description text, stability text, etag uuid)
body: |-
begin
return query
select
split_part(task_queues.task_queue_id, '/', 1) as provisioner_id,
split_part(task_queues.task_queue_id, '/', 2) as worker_type,
task_queues.expires,
task_queues.last_date_active,
task_queues.description,
task_queues.stability,
public.gen_random_uuid()
from task_queues
where
(split_part(task_queues.task_queue_id, '/', 1) = provisioner_id_in or provisioner_id_in is null) and
(split_part(task_queues.task_queue_id, '/', 2) = worker_type_in or worker_type_in is null) and
(task_queues.expires > expires_in or expires_in is null)
order by task_queue_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
expire_queue_worker_types:
description: |-
Expire queue worker types that come before `expires_in`.
Returns a count of rows that have been deleted.
deprecated: true
mode: write
serviceName: queue
args: expires_in timestamptz
returns: integer
body: |-
declare
count integer;
begin
delete from task_queues
where task_queues.expires < expires_in;
if found then
get diagnostics count = row_count;
return count;
end if;
return 0;
end
create_queue_worker:
description: |-
Create a new queue worker. Raises UNIQUE_VIOLATION if the worker already exists.
deprecated: true
mode: write
serviceName: queue
args: provisioner_id_in text, worker_type_in text, worker_group_in text, worker_id_in text, quarantine_until_in timestamptz, expires_in timestamptz, first_claim_in timestamptz, recent_tasks_in jsonb
returns: uuid
body: |-
begin
insert
into queue_workers (task_queue_id, worker_group, worker_id, quarantine_until, expires, first_claim, recent_tasks)
values (
provisioner_id_in || '/' || worker_type_in,
worker_group_in,
worker_id_in,
quarantine_until_in,
expires_in,
first_claim_in,
recent_tasks_in
);
return public.gen_random_uuid();
end
get_queue_worker:
description: |-
Get a non-expired queue worker by provisioner_id, worker_type, worker_group, and worker_id.
Workers are not considered expired until after their quarantine date expires.
deprecated: true
mode: read
serviceName: queue
args: provisioner_id_in text, worker_type_in text, worker_group_in text, worker_id_in text, expires_in timestamptz
returns: table(provisioner_id text, worker_type text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, etag uuid)
body: |-
begin
return query
select
split_part(queue_workers.task_queue_id, '/', 1) as provisioner_id,
split_part(queue_workers.task_queue_id, '/', 2) as worker_type,
queue_workers.worker_group,
queue_workers.worker_id,
queue_workers.quarantine_until,
queue_workers.expires,
queue_workers.first_claim,
queue_workers.recent_tasks,
public.gen_random_uuid()
from queue_workers
where
queue_workers.task_queue_id = provisioner_id_in || '/' || worker_type_in and
queue_workers.worker_group = worker_group_in and
queue_workers.worker_id = worker_id_in and
(queue_workers.expires > expires_in or queue_workers.quarantine_until > expires_in);
end
update_queue_worker:
serviceName: queue
description: |-
Update a queue worker's quarantine_until, expires, and recent_tasks.
All parameters must be supplied.
deprecated: true
mode: write
args: provisioner_id_in text, worker_type_in text, worker_group_in text, worker_id_in text, quarantine_until_in timestamptz, expires_in timestamptz, recent_tasks_in jsonb
returns: table(provisioner_id text, worker_type text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, etag uuid)
body: |-
begin
return query update queue_workers
set
quarantine_until = quarantine_until_in,
expires = expires_in,
recent_tasks = recent_tasks_in
where
queue_workers.task_queue_id = provisioner_id_in || '/' || worker_type_in and
queue_workers.worker_group = worker_group_in and
queue_workers.worker_id = worker_id_in
returning
split_part(queue_workers.task_queue_id, '/', 1) as provisioner_id,
split_part(queue_workers.task_queue_id, '/', 2) as worker_type,
queue_workers.worker_group,
queue_workers.worker_id,
queue_workers.quarantine_until,
queue_workers.expires,
queue_workers.first_claim,
queue_workers.recent_tasks,
public.gen_random_uuid();
end
get_queue_workers:
description: |-
Get non-expired queue workers ordered by provisioner_id, worker_type, worker_group, and worker_id.
Workers are not considered expired until after their quarantine date expires.
If the pagination arguments are both NULL, all rows are returned.
Otherwise, page_size rows are returned at offset page_offset.
deprecated: true
mode: read
serviceName: queue
args: provisioner_id_in text, worker_type_in text, expires_in timestamptz, page_size_in integer, page_offset_in integer
returns: table(provisioner_id text, worker_type text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, etag uuid)
body: |-
begin
return query
select
split_part(queue_workers.task_queue_id, '/', 1) as provisioner_id,
split_part(queue_workers.task_queue_id, '/', 2) as worker_type,
queue_workers.worker_group,
queue_workers.worker_id,
queue_workers.quarantine_until,
queue_workers.expires,
queue_workers.first_claim,
queue_workers.recent_tasks,
public.gen_random_uuid()
from queue_workers
where
(split_part(queue_workers.task_queue_id, '/', 1) = provisioner_id_in or provisioner_id_in is null) and
(split_part(queue_workers.task_queue_id, '/', 2) = worker_type_in or worker_type_in is null) and
((queue_workers.expires > expires_in and queue_workers.quarantine_until < expires_in) or get_queue_workers.expires_in is null)
order by task_queue_id, worker_group, worker_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
create_task_queue:
description: |-
Create a new task queue. Raises UNIQUE_VIOLATION if the task queue already exists.
mode: write
serviceName: queue
args: task_queue_id_in text, expires_in timestamptz, last_date_active_in timestamptz, description_in text, stability_in text
returns: uuid
body: |-
begin
insert
into task_queues (task_queue_id, expires, last_date_active, description, stability)
values (
task_queue_id_in,
expires_in,
last_date_active_in,
description_in, stability_in
);
return public.gen_random_uuid();
end
get_task_queue:
description: |-
Get a non-expired task queue by task_queue_id.
mode: read
serviceName: queue
args: task_queue_id_in text, expires_in timestamptz
returns: table(task_queue_id text, expires timestamptz, last_date_active timestamptz, description text, stability text, etag uuid)
body: |-
begin
return query
select
task_queues.task_queue_id,
task_queues.expires,
task_queues.last_date_active,
task_queues.description,
task_queues.stability,
public.gen_random_uuid()
from task_queues
where
task_queues.task_queue_id = task_queue_id_in and
task_queues.expires > expires_in;
end
update_task_queue:
serviceName: queue
description: |-
Update a task queue's expires, last_date_active, description, and stability.
All parameters must be supplied.
mode: write
args: task_queue_id_in text, expires_in timestamptz, last_date_active_in timestamptz, description_in text, stability_in text
returns: table(task_queue_id text, expires timestamptz, last_date_active timestamptz, description text, stability text, etag uuid)
body: |-
begin
return query update task_queues
set
expires = expires_in,
last_date_active = last_date_active_in,
description = description_in,
stability = stability_in
where
task_queues.task_queue_id = task_queue_id_in
returning
task_queues.task_queue_id,
task_queues.expires,
task_queues.last_date_active,
task_queues.description,
task_queues.stability,
public.gen_random_uuid();
end
get_task_queues:
description: |-
Get task queues ordered by `task_queue_id`.
If the pagination arguments are both NULL, all rows are returned.
Otherwise, page_size rows are returned at offset page_offset.
mode: read
serviceName: queue
args: task_queue_id_in text, expires_in timestamptz, page_size_in integer, page_offset_in integer
returns: table(task_queue_id text, expires timestamptz, last_date_active timestamptz, description text, stability text, etag uuid)
body: |-
begin
return query
select
task_queues.task_queue_id,
task_queues.expires,
task_queues.last_date_active,
task_queues.description,
task_queues.stability,
public.gen_random_uuid()
from task_queues
where
(task_queues.task_queue_id = task_queue_id_in or task_queue_id_in is null) and
(task_queues.expires > expires_in or expires_in is null)
order by task_queue_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
expire_task_queues:
description: |-
Expire task queues that come before `expires_in`.
Returns a count of rows that have been deleted.
mode: write
serviceName: queue
args: expires_in timestamptz
returns: integer
body: |-
declare
count integer;
begin
delete from task_queues
where task_queues.expires < expires_in;
if found then
get diagnostics count = row_count;
return count;
end if;
return 0;
end
create_queue_worker_tqid:
description: |-
Create a new queue worker. Raises UNIQUE_VIOLATION if the worker already exists.
mode: write
serviceName: queue
args: task_queue_id_in text, worker_group_in text, worker_id_in text, quarantine_until_in timestamptz, expires_in timestamptz, first_claim_in timestamptz, recent_tasks_in jsonb
returns: uuid
body: |-
begin
insert
into queue_workers (task_queue_id, worker_group, worker_id, quarantine_until, expires, first_claim, recent_tasks)
values (
task_queue_id_in,
worker_group_in,
worker_id_in,
quarantine_until_in,
expires_in,
first_claim_in,
recent_tasks_in
);
return public.gen_random_uuid();
end
get_queue_worker_tqid:
description: |-
Get a non-expired queue worker by task_queue_id, worker_group, and worker_id.
Workers are not considered expired until after their quarantine date expires.
mode: read
serviceName: queue
args: task_queue_id_in text, worker_group_in text, worker_id_in text, expires_in timestamptz
returns: table(task_queue_id text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, etag uuid)
body: |-
begin
return query
select
queue_workers.task_queue_id,
queue_workers.worker_group,
queue_workers.worker_id,
queue_workers.quarantine_until,
queue_workers.expires,
queue_workers.first_claim,
queue_workers.recent_tasks,
public.gen_random_uuid()
from queue_workers
where
queue_workers.task_queue_id = task_queue_id_in and
queue_workers.worker_group = worker_group_in and
queue_workers.worker_id = worker_id_in and
(queue_workers.expires > expires_in or queue_workers.quarantine_until > expires_in);
end
update_queue_worker_tqid:
serviceName: queue
description: |-
Update a queue worker's quarantine_until, expires, and recent_tasks.
All parameters must be supplied.
mode: write
args: task_queue_id_in text, worker_group_in text, worker_id_in text, quarantine_until_in timestamptz, expires_in timestamptz, recent_tasks_in jsonb
returns: table(task_queue_id text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, etag uuid)
body: |-
begin
return query update queue_workers
set
quarantine_until = quarantine_until_in,
expires = expires_in,
recent_tasks = recent_tasks_in
where
queue_workers.task_queue_id = task_queue_id_in and
queue_workers.worker_group = worker_group_in and
queue_workers.worker_id = worker_id_in
returning
queue_workers.task_queue_id,
queue_workers.worker_group,
queue_workers.worker_id,
queue_workers.quarantine_until,
queue_workers.expires,
queue_workers.first_claim,
queue_workers.recent_tasks,
public.gen_random_uuid();
end
get_queue_workers_tqid:
description: |-
Get non-expired queue workers ordered by task_queue_id, worker_group, and worker_id.
Workers are not considered expired until after their quarantine date expires.
If the pagination arguments are both NULL, all rows are returned.
Otherwise, page_size rows are returned at offset page_offset.
mode: read
serviceName: queue
args: task_queue_id_in text, expires_in timestamptz, page_size_in integer, page_offset_in integer
returns: table(task_queue_id text, worker_group text, worker_id text, quarantine_until timestamptz, expires timestamptz, first_claim timestamptz, recent_tasks jsonb, etag uuid)
body: |-
begin
return query
select
queue_workers.task_queue_id,
queue_workers.worker_group,
queue_workers.worker_id,
queue_workers.quarantine_until,
queue_workers.expires,
queue_workers.first_claim,
queue_workers.recent_tasks,
public.gen_random_uuid()
from queue_workers
where
(queue_workers.task_queue_id = task_queue_id_in or get_queue_workers_tqid.task_queue_id_in is null) and
((queue_workers.expires > expires_in and queue_workers.quarantine_until < expires_in) or get_queue_workers_tqid.expires_in is null)
order by task_queue_id, worker_group, worker_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
create_queue_provisioner:
description: |-
Create a new queue provisioner. Raises UNIQUE_VIOLATION if the provisioner already exists.
deprecated: true
mode: write
serviceName: queue
args: provisioner_id_in text, expires_in timestamptz, last_date_active_in timestamptz, description_in text, stability_in text, actions_in jsonb
returns: uuid
body: |-
begin
return public.gen_random_uuid();
end
get_queue_provisioner:
description: |-
Get a queue provisioner by provisioner_id.
deprecated: true
mode: read
serviceName: queue
args: provisioner_id_in text, expires_in timestamptz
returns: table(provisioner_id text, expires timestamptz, last_date_active timestamptz, description text, stability text, actions jsonb, etag uuid)
body: |-
begin
return query
select
split_part(task_queue_id, '/', 1) as provisioner_id,
max(task_queues.expires),
max(task_queues.last_date_active),
'' as description,
'experimental' as stability,
'[]'::jsonb as actions,
public.gen_random_uuid()
from task_queues
group by provisioner_id
having
split_part(task_queue_id, '/', 1) = provisioner_id_in and
max(task_queues.expires) > expires_in;
end
update_queue_provisioner:
serviceName: queue
description: |-
Update a queue provisioner's expires, last_date_active, description, stability, and actions.
All parameters must be supplied.
deprecated: true
mode: write
args: provisioner_id_in text, expires_in timestamptz, last_date_active_in timestamptz, description_in text, stability_in text, actions_in jsonb
returns: table(provisioner_id text, expires timestamptz, last_date_active timestamptz, description text, stability text, actions jsonb, etag uuid)
body: |-
begin
return query
select
split_part(task_queue_id, '/', 1) as provisioner_id,
max(task_queues.expires),
max(task_queues.last_date_active),
'' as description,
'experimental' as stability,
'[]'::jsonb as actions,
public.gen_random_uuid()
from task_queues
group by provisioner_id
having
split_part(task_queue_id, '/', 1) = provisioner_id_in;
end
get_queue_provisioners:
description: |-
Get queue provisioners ordered by `provisioner_id`.
If the pagination arguments are both NULL, all rows are returned.
Otherwise, page_size rows are returned at offset page_offset.
deprecated: true
mode: read
serviceName: queue
args: expires_in timestamptz, page_size_in integer, page_offset_in integer
returns: table(provisioner_id text, expires timestamptz, last_date_active timestamptz, description text, stability text, actions jsonb, etag uuid)
body: |-
begin
return query
select
split_part(task_queues.task_queue_id, '/', 1) as provisioner_id,
max(task_queues.expires),
max(task_queues.last_date_active),
'' as description,
'experimental' as stability,
'[]'::jsonb as actions,
public.gen_random_uuid()
from task_queues
group by provisioner_id
having (max(task_queues.expires) > expires_in or expires_in is null)
order by provisioner_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
expire_queue_provisioners:
description: |-
Expire provisioners that come before `expires_in`.
Returns a count of rows that have been deleted.
deprecated: true
mode: write
serviceName: queue
args: expires_in timestamptz
returns: integer
body: |-
begin
return 0;
end