Skip to content

Commit dcffe0c

Browse files
committed
Updated
1 parent d82381b commit dcffe0c

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

pkg/pgqueue/config/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
pgqueue "github.com/mutablelogic/go-server/pkg/pgqueue"
1414
schema "github.com/mutablelogic/go-server/pkg/pgqueue/schema"
1515
ref "github.com/mutablelogic/go-server/pkg/ref"
16-
"github.com/mutablelogic/go-server/pkg/types"
16+
types "github.com/mutablelogic/go-server/pkg/types"
1717
)
1818

1919
////////////////////////////////////////////////////////////////////////////////

pkg/pgqueue/manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ func (manager *Manager) RunTickerLoop(ctx context.Context, namespace string, ch
216216
delta := schema.TickerPeriod
217217
timer := time.NewTimer(100 * time.Millisecond)
218218
defer timer.Stop()
219-
220219
prev := time.Now()
221220

222221
// Loop until context is cancelled

pkg/pgqueue/schema/ticker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,17 @@ const (
224224
`
225225
tickerNextFunc = `
226226
-- Return the next matured ticker for a namespace
227-
CREATE OR REPLACE FUNCTION ${"schema"}.ticker_next(ns TEXT) RETURNS TABLE (
227+
CREATE OR REPLACE FUNCTION ${"schema"}.ticker_next(namespace TEXT) RETURNS TABLE (
228228
"ticker" TEXT, "interval" INTERVAL, "ns" TEXT, "ts" TIMESTAMP
229229
) AS $$
230230
WITH
231-
next_ticker AS (` + tickerSelect + `WHERE "ns" = ns AND ("ts" IS NULL OR "ts" + "interval" < NOW()) ORDER BY "ts" NULLS FIRST)
231+
next_ticker AS (` + tickerSelect + `WHERE "ns" = namespace AND ("ts" IS NULL OR "ts" + "interval" <= NOW()) ORDER BY "ts" NULLS FIRST)
232232
UPDATE
233233
${"schema"}.ticker
234234
SET
235235
"ts" = TIMEZONE('UTC', NOW())
236236
WHERE
237-
"ns" = ns AND "ticker" = (SELECT "ticker" FROM next_ticker LIMIT 1 FOR UPDATE SKIP LOCKED)
237+
"ns" = namespace AND "ticker" = (SELECT "ticker" FROM next_ticker LIMIT 1 FOR UPDATE SKIP LOCKED)
238238
RETURNING
239239
"ticker", "interval", "ns", "ts"
240240
$$ LANGUAGE SQL

0 commit comments

Comments
 (0)