forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0021.yml
158 lines (155 loc) · 5.04 KB
/
0021.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
version: 21
description: queue task groups phase 2 step 1
migrationScript: 0021-migration.sql
downgradeScript: 0021-downgrade.sql
methods:
queue_task_groups_entities_load:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: queue
args: partition_key text, row_key text
returns: table (partition_key_out text, row_key_out text, value jsonb, version integer, etag uuid)
body: |-
begin
return query
select
task_group_id,
'task-group',
jsonb_build_object(
'PartitionKey', task_group_id,
'RowKey', 'task-group',
'taskGroupId', slugid_to_uuid(task_group_id),
'schedulerId', scheduler_id,
'expires', expires) as value,
1 as version,
task_groups.etag as etag
from task_groups
where
task_groups.task_group_id = partition_key;
end
queue_task_groups_entities_create:
deprecated: true
serviceName: queue
description: See taskcluster-lib-entities
mode: write
args: pk text, rk text, properties jsonb, overwrite boolean, version integer
returns: uuid
body: |-
declare
new_etag uuid;
begin
if overwrite then
raise exception 'overwrite not implemented';
end if;
new_etag = public.gen_random_uuid();
insert into task_groups select
uuid_to_slugid(properties ->> 'taskGroupId')::text as task_group_id,
(properties ->> 'schedulerId')::text as scheduler_id,
(properties ->> 'expires')::timestamptz as expires,
new_etag as etag;
return new_etag;
end
queue_task_groups_entities_remove:
deprecated: true
serviceName: queue
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text
returns: table (etag uuid)
body: |-
begin
return query delete from task_groups
where
task_groups.task_group_id = partition_key
returning task_groups.etag;
end
queue_task_groups_entities_modify:
deprecated: true
serviceName: queue
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text, properties jsonb, version integer, old_etag uuid
returns: table (etag uuid)
body: |-
declare
new_etag uuid;
begin
-- NOTE: queue only updates expires, so that's all that's supported here
new_etag = public.gen_random_uuid();
update task_groups
set (
expires,
etag
) = (
(properties ->> 'expires')::timestamptz,
new_etag
)
where
task_groups.task_group_id = partition_key and
task_groups.etag = queue_task_groups_entities_modify.old_etag;
if found then
return query select new_etag;
return;
end if;
perform task_groups.etag from task_groups
where
task_groups.task_group_id = partition_key;
if found then
raise exception 'unsuccessful update' using errcode = 'P0004';
else
raise exception 'no such row' using errcode = 'P0002';
end if;
end
queue_task_groups_entities_scan:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: queue
args: pk text, rk text, condition text, size integer, page integer
returns: table (partition_key text, row_key text, value jsonb, version integer, etag uuid)
body: |-
declare
cond text[];
exp_cond_field text;
exp_cond_operator text;
exp_cond_operand timestamptz;
begin
if pk is not null then
raise exception 'scanning by primary key is not supported';
end if;
if not condition is null then
cond := regexp_split_to_array(condition, '\s+');
exp_cond_field := trim(cond[3], '''');
exp_cond_operator := cond[4];
exp_cond_operand := cond[5] :: timestamptz;
if exp_cond_field || exp_cond_operator != 'expires<' then
raise exception 'queue_task_group_active_sets_entities_scan only supports filtering for expired rows';
end if;
end if;
return query select
task_group_id as partition_key,
'task-group' as row_key,
jsonb_build_object(
'PartitionKey', task_group_id,
'RowKey', 'task-group',
'taskGroupId', slugid_to_uuid(task_group_id),
'schedulerId', scheduler_id,
'expires', expires) as value,
1 as version,
task_groups.etag as etag from task_groups
where
case
when exp_cond_field = 'expires' then expires < exp_cond_operand
else true
end
order by task_groups.task_group_id
limit case
when (size is not null and size > 0) then size + 1
else null
end
offset case
when (page is not null and page > 0) then page
else 0
end;
end