-
Notifications
You must be signed in to change notification settings - Fork 250
/
0081.yml
99 lines (98 loc) · 2.56 KB
/
0081.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
version: 81
description: seal task group to prevent new tasks from being added to it
migrationScript: |-
begin
alter table task_groups add column sealed timestamptz null;
end
downgradeScript: |-
begin
alter table task_groups drop column sealed;
end
methods:
get_task_group:
deprecated: true
get_task_group2:
description: |-
Get a task group with sealed column.
mode: read
serviceName: queue
args: task_group_id_in text
returns: |-
table(
task_group_id text,
scheduler_id text,
expires timestamptz,
sealed timestamptz
)
body: |-
begin
return query
select
task_groups.task_group_id,
task_groups.scheduler_id,
task_groups.expires,
task_groups.sealed
from task_groups
where task_groups.task_group_id = task_group_id_in;
end
is_task_group_sealed:
description: |-
Return true if task group was sealed.
mode: read
serviceName: queue
args: task_group_id_in text
returns: boolean
body: |-
begin
perform 1
from task_groups
where
task_groups.task_group_id = task_group_id_in and
task_groups.sealed is not null
limit 1;
return found;
end
seal_task_group:
description: |-
Marks task group as sealed by adding sealed timestamp to it.
mode: write
serviceName: queue
args: task_group_id_in text
returns: |-
table(
task_group_id text,
scheduler_id text,
expires timestamptz,
sealed timestamptz
)
body: |-
declare
updated_row task_groups%ROWTYPE;
begin
UPDATE task_groups
SET sealed = NOW()
WHERE task_groups.task_group_id = task_group_id_in
AND task_groups.sealed IS NULL
RETURNING
task_groups.task_group_id,
task_groups.scheduler_id,
task_groups.expires,
task_groups.sealed
INTO updated_row;
IF FOUND THEN
return query select
updated_row.task_group_id,
updated_row.scheduler_id,
updated_row.expires,
updated_row.sealed;
ELSE
-- If no rows were updated, return the existing row
return query SELECT
task_groups.task_group_id,
task_groups.scheduler_id,
task_groups.expires,
task_groups.sealed
FROM task_groups
WHERE task_groups.task_group_id = task_group_id_in;
END IF;
end