@@ -330,7 +330,7 @@ const (
330
330
`
331
331
taskCreateInsertFunc = `
332
332
-- Insert a new payload into a queue
333
- CREATE OR REPLACE FUNCTION ${"schema"}.queue_insert(ns TEXT, q TEXT, p JSONB, delayed_at TIMESTAMP) RETURNS BIGINT AS $$
333
+ CREATE OR REPLACE FUNCTION ${"schema"}.queue_insert(n TEXT, q TEXT, p JSONB, delayed_at TIMESTAMP) RETURNS BIGINT AS $$
334
334
WITH defaults AS (
335
335
-- Select the retries and ttl from the queue defaults
336
336
SELECT
@@ -342,13 +342,13 @@ const (
342
342
FROM
343
343
${"schema"}."queue"
344
344
WHERE
345
- "queue" = q AND "ns" = ns
345
+ "queue" = q AND "ns" = n
346
346
LIMIT
347
347
1
348
348
) INSERT INTO
349
349
${"schema"}."task" ("ns", "queue", "payload", "delayed_at", "retries", "initial_retries", "dies_at")
350
350
SELECT
351
- ns , q, p, CASE
351
+ n , q, p, CASE
352
352
WHEN "delayed_at" IS NULL THEN NULL
353
353
WHEN "delayed_at" < TIMEZONE('UTC', NOW()) THEN (NOW() AT TIME ZONE 'UTC')
354
354
ELSE "delayed_at"
@@ -379,7 +379,7 @@ const (
379
379
`
380
380
taskRetainFunc = `
381
381
-- A specific worker locks a task in a queue for processing
382
- CREATE OR REPLACE FUNCTION ${"schema"}.queue_lock(ns TEXT, w TEXT) RETURNS BIGINT AS $$
382
+ CREATE OR REPLACE FUNCTION ${"schema"}.queue_lock(n TEXT, w TEXT) RETURNS BIGINT AS $$
383
383
UPDATE ${"schema"}."task" SET
384
384
"started_at" = TIMEZONE('UTC', NOW()), "worker" = w, "result" = 'null'
385
385
WHERE "id" = (
@@ -388,7 +388,7 @@ const (
388
388
FROM
389
389
${"schema"}."task"
390
390
WHERE
391
- "ns" = ns
391
+ "ns" = n
392
392
AND
393
393
("started_at" IS NULL AND "finished_at" IS NULL AND "dies_at" > TIMEZONE('UTC', NOW()))
394
394
AND
@@ -471,7 +471,7 @@ const (
471
471
`
472
472
taskCleanFunc = `
473
473
-- Cleanup tasks in a queue which are in an end state
474
- CREATE OR REPLACE FUNCTION ${"schema"}.queue_clean(ns TEXT, q TEXT) RETURNS TABLE (
474
+ CREATE OR REPLACE FUNCTION ${"schema"}.queue_clean(n TEXT, q TEXT) RETURNS TABLE (
475
475
"id" BIGINT, "queue" TEXT, "ns" TEXT, "payload" JSONB, "result" JSONB, "worker" TEXT, "created_at" TIMESTAMP, "delayed_at" TIMESTAMP, "started_at" TIMESTAMP, "finished_at" TIMESTAMP, "dies_at" TIMESTAMP, "retries" INTEGER
476
476
) AS $$
477
477
DELETE FROM
@@ -484,7 +484,7 @@ const (
484
484
FROM
485
485
${"schema"}."task"
486
486
WHERE
487
- "ns" = ns AND "queue" = q
487
+ "ns" = n AND "queue" = q
488
488
AND
489
489
(dies_at IS NULL OR dies_at < TIMEZONE('UTC', NOW()))
490
490
) SELECT
0 commit comments