forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0049.yml
761 lines (756 loc) · 29.7 KB
/
0049.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
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
version: 49
description: Remove unnecessary etag columns from DB tables
migrationScript: |-
begin
alter table clients drop column etag;
alter table github_builds drop column etag;
alter table hooks drop column etag;
alter table hooks_last_fires drop column etag;
alter table hooks_queues drop column etag;
alter table indexed_tasks drop column etag;
alter table denylisted_notifications drop column etag;
alter table cache_purges drop column etag;
alter table access_tokens drop column etag;
alter table authorization_codes drop column etag;
alter table sessions drop column etag;
alter table queue_provisioners drop column etag;
alter table queue_worker_types drop column etag;
alter table queue_workers drop column etag;
alter table task_groups drop column etag;
alter table task_dependencies drop column etag;
alter table queue_artifacts drop column etag;
alter table tasks drop column etag;
alter table worker_pool_errors drop column etag;
alter table worker_pools drop column etag;
alter table index_namespaces drop column etag;
end
downgradeScript: |-
begin
alter table clients add column etag uuid not null default public.gen_random_uuid();
alter table github_builds add column etag uuid not null default public.gen_random_uuid();
alter table hooks add column etag uuid not null default public.gen_random_uuid();
alter table hooks_last_fires add column etag uuid not null default public.gen_random_uuid();
alter table hooks_queues add column etag uuid not null default public.gen_random_uuid();
alter table indexed_tasks add column etag uuid not null default public.gen_random_uuid();
alter table denylisted_notifications add column etag uuid not null default public.gen_random_uuid();
alter table cache_purges add column etag uuid not null default public.gen_random_uuid();
alter table access_tokens add column etag uuid not null default public.gen_random_uuid();
alter table authorization_codes add column etag uuid not null default public.gen_random_uuid();
alter table sessions add column etag uuid not null default public.gen_random_uuid();
alter table queue_provisioners add column etag uuid not null default public.gen_random_uuid();
alter table queue_worker_types add column etag uuid not null default public.gen_random_uuid();
alter table queue_workers add column etag uuid not null default public.gen_random_uuid();
alter table task_groups add column etag uuid not null default public.gen_random_uuid();
alter table task_dependencies add column etag uuid not null default public.gen_random_uuid();
alter table queue_artifacts add column etag uuid not null default public.gen_random_uuid();
alter table tasks add column etag uuid not null default public.gen_random_uuid();
alter table worker_pool_errors add column etag uuid not null default public.gen_random_uuid();
alter table worker_pools add column etag uuid not null default public.gen_random_uuid();
alter table index_namespaces add column etag uuid not null default public.gen_random_uuid();
end
methods:
create_hooks_queue:
description: |-
Create a new hooks queue. Raises UNIQUE_VIOLATION if the hook already exists.
mode: write
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, queue_name_in text, bindings_in jsonb
returns: uuid
body: |-
begin
insert
into hooks_queues (hook_group_id, hook_id, queue_name, bindings)
values (hook_group_id_in, hook_id_in, queue_name_in, bindings_in);
return public.gen_random_uuid();
end
delete_hooks_queue:
description: |-
Delete a hooks queue.
mode: write
serviceName: hooks
args: hook_group_id_in text, hook_id_in text
returns: void
body: |-
begin
delete from hooks_queues
where
hooks_queues.hook_group_id = hook_group_id_in and
hooks_queues.hook_id = hook_id_in;
end
get_hooks_queues:
description: |-
Get hooks queues ordered by `hook_group_id` and `hook_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: hooks
args: page_size_in integer, page_offset_in integer
returns: table(hook_group_id text, hook_id text, queue_name text, bindings jsonb, etag uuid)
body: |-
begin
return query
select
hooks_queues.hook_group_id,
hooks_queues.hook_id,
hooks_queues.queue_name,
hooks_queues.bindings,
public.gen_random_uuid()
from hooks_queues
order by hook_group_id, hook_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
update_hooks_queue_bindings:
description: |-
Update bindings of a hooks queue. If no such queue exists,
the return value is an empty set.
mode: write
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, bindings_in jsonb
returns: table(hook_group_id text, hook_id text, queue_name text, bindings jsonb, etag uuid)
body: |-
begin
return query update hooks_queues
set
bindings = bindings_in
where
hooks_queues.hook_group_id = hook_group_id_in and
hooks_queues.hook_id = hook_id_in
returning
hooks_queues.hook_group_id,
hooks_queues.hook_id,
hooks_queues.queue_name,
hooks_queues.bindings,
public.gen_random_uuid();
end
create_last_fire:
description: |-
Create a new hook last fire. Raises UNIQUE_VIOLATION if the hook already exists.
mode: write
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, fired_by_in text, task_id_in text, task_create_time_in timestamptz, result_in text, error_in text
returns: uuid
body: |-
begin
insert
into hooks_last_fires (hook_group_id, hook_id, fired_by, task_id, task_create_time, result, error)
values (hook_group_id_in, hook_id_in, fired_by_in, task_id_in, task_create_time_in, result_in, error_in);
return public.gen_random_uuid();
end
get_last_fire:
description: |-
Get a hook last fire.
mode: read
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, task_id_in text
returns: table(hook_group_id text, hook_id text, fired_by text, task_id text, task_create_time timestamptz, result text, error text, etag uuid)
body: |-
begin
return query
select
hooks_last_fires.hook_group_id,
hooks_last_fires.hook_id,
hooks_last_fires.fired_by,
hooks_last_fires.task_id,
hooks_last_fires.task_create_time,
hooks_last_fires.result,
hooks_last_fires.error,
public.gen_random_uuid()
from hooks_last_fires
where
hooks_last_fires.hook_group_id = hook_group_id_in and
hooks_last_fires.hook_id = hook_id_in and
hooks_last_fires.task_id = task_id_in;
end
get_last_fires:
description: |-
Get hooks last fires filtered by the `hook_group_id` and `hook_id` arguments,
ordered by `hook_group_id`, `hook_id`, and `worker_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: hooks
args: hook_group_id_in text, hook_id_in text, page_size_in integer, page_offset_in integer
returns: table(hook_group_id text, hook_id text, fired_by text, task_id text, task_create_time timestamptz, result text, error text, etag uuid)
body: |-
begin
return query
select
hooks_last_fires.hook_group_id,
hooks_last_fires.hook_id,
hooks_last_fires.fired_by,
hooks_last_fires.task_id,
hooks_last_fires.task_create_time,
hooks_last_fires.result,
hooks_last_fires.error,
public.gen_random_uuid()
from hooks_last_fires
where
hooks_last_fires.hook_group_id = hook_group_id_in and
hooks_last_fires.hook_id = hook_id_in
order by hook_group_id, hook_id, task_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
get_github_build:
description: |-
Get a github build. The returned table will have one or zero rows.
mode: read
serviceName: github
args: task_group_id_in text
returns: table (organization text, repository text, sha text, task_group_id text, state text, created timestamptz, updated timestamptz, installation_id integer, event_type text, event_id text, etag uuid)
body: |-
begin
return query
select
github_builds.organization,
github_builds.repository,
github_builds.sha,
github_builds.task_group_id,
github_builds.state,
github_builds.created,
github_builds.updated,
github_builds.installation_id,
github_builds.event_type,
github_builds.event_id,
public.gen_random_uuid()
from github_builds
where github_builds.task_group_id = task_group_id_in;
end
get_github_builds:
description: |-
Get github builds.
mode: read
serviceName: github
args: page_size_in integer, page_offset_in integer, organization_in text, repository_in text, sha_in text
returns: table (organization text, repository text, sha text, task_group_id text, state text, created timestamptz, updated timestamptz, installation_id integer, event_type text, event_id text, etag uuid)
body: |-
begin
return query
select
github_builds.organization,
github_builds.repository,
github_builds.sha,
github_builds.task_group_id,
github_builds.state,
github_builds.created,
github_builds.updated,
github_builds.installation_id,
github_builds.event_type,
github_builds.event_id,
public.gen_random_uuid()
from github_builds
where
(organization_in is null or github_builds.organization = organization_in) and
(repository_in is null or github_builds.repository = repository_in) and
(sha_in is null or github_builds.sha = sha_in)
order by github_builds.updated asc
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
set_github_build_state:
description: |-
Only update the state of a build and update the `updated` timestamp
mode: write
serviceName: github
args: task_group_id_in text, state_in text
returns: void
body: |-
begin
update github_builds
set (state, updated) = (
state_in,
now()
) where github_builds.task_group_id = task_group_id_in;
if not found then
raise exception 'no such row' using errcode = 'P0002';
end if;
end
add_denylist_address:
description: |-
If the denylist address already exists, this is a no-op. Otherwise, add the denylist
address for the taskcluster-notify service, with a new random etag.
mode: write
serviceName: notify
args: notification_type_in text, notification_address_in text
returns: void
body: |-
begin
insert into denylisted_notifications(notification_type, notification_address)
values (
notification_type_in,
notification_address_in
) on conflict do nothing;
end
purge_cache:
serviceName: purge_cache
description: |-
Publish a request to purge caches with name `cache_name_in`
on `provisioner_id_in`/`worker_type_in` workers.
mode: write
args: provisioner_id_in text, worker_type_in text, cache_name_in text, before_in timestamptz, expires_in timestamptz
returns: void
body: |-
begin
insert into cache_purges(provisioner_id, worker_type, cache_name, before, expires)
values (
provisioner_id_in,
worker_type_in,
cache_name_in,
before_in,
expires_in
) on conflict (provisioner_id, worker_type, cache_name) do
update
set (before, expires) = (before_in, expires_in)
where cache_purges.provisioner_id = provisioner_id_in and cache_purges.worker_type = worker_type_in and cache_purges.cache_name = cache_name_in;
end
create_queue_provisioner:
description: |-
Create a new queue provisioner. Raises UNIQUE_VIOLATION if the provisioner already exists.
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
insert
into queue_provisioners (provisioner_id, expires, last_date_active, description, stability, actions)
values (provisioner_id_in, expires_in, last_date_active_in, description_in, stability_in, actions_in);
return public.gen_random_uuid();
end
get_queue_provisioner:
description: |-
Get a queue provisioner by provisioner_id.
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
queue_provisioners.provisioner_id,
queue_provisioners.expires,
queue_provisioners.last_date_active,
queue_provisioners.description,
queue_provisioners.stability,
queue_provisioners.actions,
public.gen_random_uuid()
from queue_provisioners
where
queue_provisioners.provisioner_id = provisioner_id_in and
queue_provisioners.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.
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: |-
declare
new_etag uuid := public.gen_random_uuid();
begin
return query update queue_provisioners
set
expires = expires_in,
last_date_active = last_date_active_in,
description = description_in,
stability = stability_in,
actions = actions_in
where
queue_provisioners.provisioner_id = provisioner_id_in
returning
queue_provisioners.provisioner_id,
queue_provisioners.expires,
queue_provisioners.last_date_active,
queue_provisioners.description,
queue_provisioners.stability,
queue_provisioners.actions,
public.gen_random_uuid();
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.
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
queue_provisioners.provisioner_id,
queue_provisioners.expires,
queue_provisioners.last_date_active,
queue_provisioners.description,
queue_provisioners.stability,
queue_provisioners.actions,
public.gen_random_uuid()
from queue_provisioners
where (queue_provisioners.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
create_queue_worker_type:
description: |-
Create a new queue worker type. Raises UNIQUE_VIOLATION if the worker type already exists.
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 queue_worker_types (provisioner_id, worker_type, 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.
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
queue_worker_types.provisioner_id,
queue_worker_types.worker_type,
queue_worker_types.expires,
queue_worker_types.last_date_active,
queue_worker_types.description,
queue_worker_types.stability,
public.gen_random_uuid()
from queue_worker_types
where
queue_worker_types.provisioner_id = provisioner_id_in and
queue_worker_types.worker_type = worker_type_in and
queue_worker_types.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.
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 queue_worker_types
set
expires = expires_in,
last_date_active = last_date_active_in,
description = description_in,
stability = stability_in
where
queue_worker_types.provisioner_id = provisioner_id_in and
queue_worker_types.worker_type = worker_type_in
returning
queue_worker_types.provisioner_id,
queue_worker_types.worker_type,
queue_worker_types.expires,
queue_worker_types.last_date_active,
queue_worker_types.description,
queue_worker_types.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.
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
queue_worker_types.provisioner_id,
queue_worker_types.worker_type,
queue_worker_types.expires,
queue_worker_types.last_date_active,
queue_worker_types.description,
queue_worker_types.stability,
public.gen_random_uuid()
from queue_worker_types
where
(queue_worker_types.provisioner_id = provisioner_id_in or provisioner_id_in is null) and
(queue_worker_types.worker_type = worker_type_in or worker_type_in is null) and
(queue_worker_types.expires > expires_in or expires_in is null)
order by provisioner_id, worker_type
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
create_queue_worker:
description: |-
Create a new queue worker. Raises UNIQUE_VIOLATION if the worker already exists.
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 (provisioner_id, worker_type, 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.
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
queue_workers.provisioner_id,
queue_workers.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.provisioner_id = provisioner_id_in and
queue_workers.worker_type = 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.
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.provisioner_id = provisioner_id_in and
queue_workers.worker_type = worker_type_in and
queue_workers.worker_group = worker_group_in and
queue_workers.worker_id = worker_id_in
returning
queue_workers.provisioner_id,
queue_workers.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.
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
queue_workers.provisioner_id,
queue_workers.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.provisioner_id = provisioner_id_in or get_queue_workers.provisioner_id_in is null) and
(queue_workers.worker_type = worker_type_in or get_queue_workers.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 provisioner_id, worker_type, worker_group, worker_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
ensure_task_group:
description: |-
Ensure that the given task group exists, has the matching scheduler_id,
and has an expiration greater than the given expiration. Expiration is
bumped by an hour at a time to avoid unnecessary updates. This returns
23505 (UNIQUE_VIOLATION) when the group exists with a different
scheduler_id.
mode: write
serviceName: queue
args: |-
task_group_id_in text,
scheduler_id_in text,
expires_in timestamptz
returns: void
body: |-
declare
task_group task_groups%ROWTYPE;
begin
select *
from task_groups
where task_groups.task_group_id = task_group_id_in
for update
into task_group;
-- insert with expiration one hour later than given
if task_group.task_group_id is NULL then
begin
insert
into task_groups (task_group_id, scheduler_id, expires)
values (
task_group_id_in,
scheduler_id_in,
expires_in + interval '1 hour'
);
return;
exception
when unique_violation then
-- we raced with another call's insert, so get that inserted row
select *
from task_groups
where task_groups.task_group_id = task_group_id_in
for update
into task_group;
end;
end if;
if task_group.scheduler_id != scheduler_id_in then
raise exception 'task group exists with different scheduler_id'
using errcode = '23505';
end if;
-- if necessary, update the expires value
if expires_in > task_group.expires then
update task_groups
set expires = expires_in + interval '1 hour'
where task_groups.task_group_id = task_group_id_in;
end if;
end
create_task:
description: |-
Create a new task, without scheduling it, and with empty values
for the status information.
mode: write
serviceName: queue
args: |-
task_id text,
provisioner_id text,
worker_type text,
scheduler_id text,
task_group_id text,
dependencies jsonb,
requires task_requires,
routes jsonb,
priority task_priority,
retries integer,
created timestamptz,
deadline timestamptz,
expires timestamptz,
scopes jsonb,
payload jsonb,
metadata jsonb,
tags jsonb,
extra jsonb
returns: void
body: |-
begin
insert
into tasks (
task_id,
provisioner_id,
worker_type,
scheduler_id,
task_group_id,
dependencies,
requires,
routes,
priority,
retries,
created,
deadline,
expires,
scopes,
payload,
metadata,
tags,
extra,
retries_left,
runs,
taken_until,
ever_resolved
)
values (
task_id,
provisioner_id,
worker_type,
scheduler_id,
task_group_id,
dependencies,
requires,
routes,
priority,
retries,
created,
deadline,
expires,
scopes,
payload,
metadata,
tags,
extra,
-- default values for the mutable bits
retries,
jsonb_build_array(),
null, -- not taken
false
);
end
add_task_dependency:
description: |-
Create an un-satisfied task dependency between the two tasks, with the given
requirement style and expiration. If the dependency already exists, nothing
happens.
mode: write
serviceName: queue
args: dependent_task_id_in text, required_task_id_in text, requires_in task_requires, expires_in timestamptz
returns: void
body: |-
begin
insert
into task_dependencies (dependent_task_id, required_task_id, requires, satisfied, expires)
values (
dependent_task_id_in,
required_task_id_in,
requires_in,
false,
expires_in
)
on conflict do nothing;
end