Skip to content

Commit c359835

Browse files
committed
prefix names in in data apis with queue_*
1 parent c78acab commit c359835

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

nix/tests/sql/pgmq_rest_wrapper.sql renamed to nix/tests/sql/pgmq_data_api_wrapper.sql

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ alter role authenticated set statement_timeout = '8s';
6767
create schema if not exists queues_public;
6868
grant usage on schema queues_public to postgres, anon, authenticated, service_role;
6969

70-
create or replace function queues_public.pop(
70+
create or replace function queues_public.queue_pop(
7171
queue_name text
7272
)
7373
returns setof pgmq.message_record
@@ -83,10 +83,10 @@ begin
8383
end;
8484
$$;
8585

86-
comment on function queues_public.pop(queue_name text) is 'Retrieves and locks the next message from the specified queue.';
86+
comment on function queues_public.queue_pop(queue_name text) is 'Retrieves and locks the next message from the specified queue.';
8787

8888

89-
create or replace function queues_public.send(
89+
create or replace function queues_public.queue_send(
9090
queue_name text,
9191
message jsonb,
9292
sleep_seconds integer default 0 -- renamed from 'delay'
@@ -106,10 +106,10 @@ begin
106106
end;
107107
$$;
108108

109-
comment on function queues_public.send(queue_name text, message jsonb, sleep_seconds integer) is 'Sends a message to the specified queue, optionally delaying its availability by a number of seconds.';
109+
comment on function queues_public.queue_send(queue_name text, message jsonb, sleep_seconds integer) is 'Sends a message to the specified queue, optionally delaying its availability by a number of seconds.';
110110

111111

112-
create or replace function queues_public.send_batch(
112+
create or replace function queues_public.queue_send_batch(
113113
queue_name text,
114114
messages jsonb[],
115115
sleep_seconds integer default 0 -- renamed from 'delay'
@@ -129,10 +129,10 @@ begin
129129
end;
130130
$$;
131131

132-
comment on function queues_public.send_batch(queue_name text, messages jsonb[], sleep_seconds integer) is 'Sends a batch of messages to the specified queue, optionally delaying their availability by a number of seconds.';
132+
comment on function queues_public.queue_send_batch(queue_name text, messages jsonb[], sleep_seconds integer) is 'Sends a batch of messages to the specified queue, optionally delaying their availability by a number of seconds.';
133133

134134

135-
create or replace function queues_public.archive(
135+
create or replace function queues_public.queue_archive(
136136
queue_name text,
137137
message_id bigint
138138
)
@@ -149,10 +149,10 @@ begin
149149
end;
150150
$$;
151151

152-
comment on function queues_public.archive(queue_name text, message_id bigint) is 'Archives a message by moving it from the queue to a permanent archive.';
152+
comment on function queues_public.queue_archive(queue_name text, message_id bigint) is 'Archives a message by moving it from the queue to a permanent archive.';
153153

154154

155-
create or replace function queues_public.archive(
155+
create or replace function queues_public.queue_archive(
156156
queue_name text,
157157
message_id bigint
158158
)
@@ -169,10 +169,10 @@ begin
169169
end;
170170
$$;
171171

172-
comment on function queues_public.archive(queue_name text, message_id bigint) is 'Archives a message by moving it from the queue to a permanent archive.';
172+
comment on function queues_public.queue_archive(queue_name text, message_id bigint) is 'Archives a message by moving it from the queue to a permanent archive.';
173173

174174

175-
create or replace function queues_public.delete(
175+
create or replace function queues_public.queue_delete(
176176
queue_name text,
177177
message_id bigint
178178
)
@@ -189,9 +189,9 @@ begin
189189
end;
190190
$$;
191191

192-
comment on function queues_public.delete(queue_name text, message_id bigint) is 'Permanently deletes a message from the specified queue.';
192+
comment on function queues_public.queue_delete(queue_name text, message_id bigint) is 'Permanently deletes a message from the specified queue.';
193193

194-
create or replace function queues_public.read(
194+
create or replace function queues_public.queue_read(
195195
queue_name text,
196196
sleep_seconds integer,
197197
n integer
@@ -211,26 +211,26 @@ begin
211211
end;
212212
$$;
213213

214-
comment on function queues_public.read(queue_name text, sleep_seconds integer, n integer) is 'Reads up to "n" messages from the specified queue with an optional "sleep_seconds" (visibility timeout).';
214+
comment on function queues_public.queue_read(queue_name text, sleep_seconds integer, n integer) is 'Reads up to "n" messages from the specified queue with an optional "sleep_seconds" (visibility timeout).';
215215

216216
-- Grant execute permissions on wrapper functions to roles
217-
grant execute on function queues_public.pop(text) to postgres, service_role, anon, authenticated;
217+
grant execute on function queues_public.queue_pop(text) to postgres, service_role, anon, authenticated;
218218
grant execute on function pgmq.pop(text) to postgres, service_role, anon, authenticated;
219219

220220

221-
grant execute on function queues_public.send(text, jsonb, integer) to postgres, service_role, anon, authenticated;
221+
grant execute on function queues_public.queue_send(text, jsonb, integer) to postgres, service_role, anon, authenticated;
222222
grant execute on function pgmq.send(text, jsonb, integer) to postgres, service_role, anon, authenticated;
223223

224-
grant execute on function queues_public.send_batch(text, jsonb[], integer) to postgres, service_role, anon, authenticated;
224+
grant execute on function queues_public.queue_send_batch(text, jsonb[], integer) to postgres, service_role, anon, authenticated;
225225
grant execute on function pgmq.send_batch(text, jsonb[], integer) to postgres, service_role, anon, authenticated;
226226

227-
grant execute on function queues_public.archive(text, bigint) to postgres, service_role, anon, authenticated;
227+
grant execute on function queues_public.queue_archive(text, bigint) to postgres, service_role, anon, authenticated;
228228
grant execute on function pgmq.archive(text, bigint) to postgres, service_role, anon, authenticated;
229229

230-
grant execute on function queues_public.delete(text, bigint) to postgres, service_role, anon, authenticated;
230+
grant execute on function queues_public.queue_delete(text, bigint) to postgres, service_role, anon, authenticated;
231231
grant execute on function pgmq.delete(text, bigint) to postgres, service_role, anon, authenticated;
232232

233-
grant execute on function queues_public.read(text, integer, integer) to postgres, service_role, anon, authenticated;
233+
grant execute on function queues_public.queue_read(text, integer, integer) to postgres, service_role, anon, authenticated;
234234
grant execute on function pgmq.read(text, integer, integer, jsonb) to postgres, service_role, anon, authenticated;
235235

236236
-- For the service role, we want full access
@@ -255,7 +255,7 @@ begin;
255255
set local role service_role;
256256

257257
-- Should Succeed
258-
select queues_public.send(
258+
select queues_public.queue_send(
259259
queue_name := 'baz',
260260
message := '{}'
261261
);
@@ -265,7 +265,7 @@ begin;
265265
set local role anon;
266266

267267
-- Should Fail
268-
select queues_public.send(
268+
select queues_public.queue_send(
269269
queue_name := 'baz',
270270
message := '{}'
271271
);
@@ -275,7 +275,7 @@ begin;
275275
set local role authenticated;
276276

277277
-- Should Fail
278-
select queues_public.send(
278+
select queues_public.queue_send(
279279
queue_name := 'baz',
280280
message := '{}'
281281
);
@@ -287,7 +287,7 @@ begin;
287287
set local role service_role;
288288

289289
-- Should Succeed
290-
select queues_public.read(
290+
select queues_public.queue_read(
291291
queue_name := 'baz',
292292
sleep_seconds := 0,
293293
n := 1
@@ -298,7 +298,7 @@ begin;
298298
set local role anon;
299299

300300
-- Should Fail
301-
select queues_public.read(
301+
select queues_public.queue_read(
302302
queue_name := 'baz',
303303
sleep_seconds := 0,
304304
n := 1
@@ -309,7 +309,7 @@ begin;
309309
set local role authenticated;
310310

311311
-- Should Fail
312-
select queues_public.read(
312+
select queues_public.queue_read(
313313
queue_name := 'baz',
314314
sleep_seconds := 0,
315315
n := 1
@@ -392,7 +392,7 @@ begin;
392392
set local role anon;
393393

394394
-- Should Fail
395-
select queues_public.read(
395+
select queues_public.queue_read(
396396
queue_name := 'qux',
397397
sleep_seconds := 0,
398398
n := 1
@@ -404,26 +404,26 @@ begin;
404404
set local role authenticated;
405405

406406
-- Should succeed
407-
select queues_public.send(
407+
select queues_public.queue_send(
408408
queue_name := 'qux',
409409
message := '{}'
410410
);
411411

412-
select queues_public.send_batch(
412+
select queues_public.queue_send_batch(
413413
queue_name := 'qux',
414414
messages := array['{"a": 1}', '{"b": 2}']::jsonb[]
415415
);
416416

417-
select queues_public.pop(
417+
select queues_public.queue_pop(
418418
queue_name := 'qux'
419419
);
420420

421-
select queues_public.delete(
421+
select queues_public.queue_delete(
422422
queue_name := 'qux',
423423
message_id := 2
424424
);
425425

426-
select queues_public.archive(
426+
select queues_public.queue_archive(
427427
queue_name := 'qux',
428428
message_id := 3
429429
);
@@ -449,7 +449,7 @@ begin;
449449
set local role authenticated;
450450

451451
-- Should fail
452-
select queues_public.send(
452+
select queues_public.queue_send(
453453
queue_name := 'waldo',
454454
message := '{}'
455455
);

0 commit comments

Comments
 (0)