/
0038.yml
148 lines (146 loc) · 4.72 KB
/
0038.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
version: 38
description: web-server sessions phase 2
migrationScript: 0038-migration.sql
downgradeScript: 0038-downgrade.sql
methods:
session_storage_table_entities_load:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: web_server
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
end
session_storage_table_entities_create:
deprecated: true
serviceName: web_server
description: See taskcluster-lib-entities
mode: write
args: pk text, rk text, properties jsonb, overwrite boolean, version integer
returns: uuid
body: |-
begin
raise exception 'unsuccessful create' using errcode = 'P0004';
end
session_storage_table_entities_remove:
deprecated: true
serviceName: web_server
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text
returns: table (etag uuid)
body: |-
begin
raise exception 'unsuccessful delete' using errcode = 'P0004';
end
session_storage_table_entities_modify:
deprecated: true
serviceName: web_server
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: |-
begin
raise exception 'unsuccessful update' using errcode = 'P0004';
end
session_storage_table_entities_scan:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: web_server
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: |-
begin
end
session_add:
description: |-
Set a session.
If no session exists with hashed session id `hashed_session_id_in`,
a new row is inserted, otherwise the existing session's data is replaced
with the data in `data_in`.
mode: write
serviceName: web_server
args: hashed_session_id_in text, encrypted_session_id_in jsonb, data_in jsonb, expires_in timestamptz
returns: void
body: |-
begin
insert into sessions(hashed_session_id, encrypted_session_id, data, expires)
values (
hashed_session_id_in,
encrypted_session_id_in,
data_in,
expires_in
) on conflict (hashed_session_id) do
update
set (encrypted_session_id, data, expires) = (encrypted_session_id_in, data_in, expires_in)
where sessions.hashed_session_id = session_add.hashed_session_id_in;
end
session_load:
description: Returns the session for a given hashed session id.
mode: read
serviceName: web_server
args: hashed_session_id_in text
returns: table(hashed_session_id text, encrypted_session_id jsonb, data jsonb, expires timestamptz)
body: |-
begin
return query
select sessions.hashed_session_id, sessions.encrypted_session_id, sessions.data, sessions.expires from sessions
where sessions.hashed_session_id = hashed_session_id_in;
end
session_touch:
description: |-
Touch a given session given a hashed session id and session `data`.
If the hashed session id does not exist, then an error code `P0002` will be thrown.
mode: write
serviceName: web_server
args: hashed_session_id_in text, data_in jsonb, expires_in timestamptz
returns: void
body: |-
begin
perform 1 from sessions where sessions.hashed_session_id = hashed_session_id_in;
if found then
update sessions
set
data = data_in,
expires = expires_in
where sessions.hashed_session_id = hashed_session_id_in;
return;
else
raise exception 'no such row' using errcode = 'P0002';
end if;
end
session_remove:
description: Removes a web session
mode: write
serviceName: web_server
args: hashed_session_id_in text
returns: void
body: |-
begin
delete from sessions
where
sessions.hashed_session_id = hashed_session_id_in;
end
expire_sessions:
description: |-
Delete sessions that expire before the current time.
Returns a count of rows that have been deleted.
mode: write
serviceName: web_server
args: ''
returns: integer
body: |-
declare
count integer;
begin
delete from sessions where sessions.expires < now();
if found then
get diagnostics count = row_count;
return count;
end if;
return 0;
end