| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | |
| 5 | package workerdb |
| 6 | |
| 7 | import ( |
| 8 | "context" |
| 9 | |
| 10 | "github.com/jackc/pgx/v5/pgtype" |
| 11 | ) |
| 12 | |
| 13 | type Querier interface { |
| 14 | // Atomically claim the oldest runnable job of a given kind. Workers |
| 15 | // supply their own instance ID as locked_by so admins can see who's |
| 16 | // holding what. Returns pgx.ErrNoRows when the queue is empty for |
| 17 | // that kind. |
| 18 | ClaimJob(ctx context.Context, db DBTX, arg ClaimJobParams) (Job, error) |
| 19 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 20 | // |
| 21 | // Jobs queue. The dispatch query uses FOR UPDATE SKIP LOCKED — the |
| 22 | // canonical Postgres pattern for safe concurrent dequeue. Multiple |
| 23 | // workers can run ClaimJob concurrently; each gets a different row. |
| 24 | // Insert a new job. run_at defaults to now() so the job is immediately |
| 25 | // runnable; pass a future timestamp for delayed work. The returned row |
| 26 | // carries the assigned ID, which callers persist when the enqueue is |
| 27 | // done inside a wider transaction. |
| 28 | EnqueueJob(ctx context.Context, db DBTX, arg EnqueueJobParams) (Job, error) |
| 29 | // Single-row lookup by id. Used in tests and the admin panel. |
| 30 | GetJob(ctx context.Context, db DBTX, id int64) (Job, error) |
| 31 | GetPushEvent(ctx context.Context, db DBTX, id int64) (PushEvent, error) |
| 32 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 33 | // |
| 34 | // push_events records what landed; the post-receive hook writes; the |
| 35 | // push:process job consumes. |
| 36 | InsertPushEvent(ctx context.Context, db DBTX, arg InsertPushEventParams) (PushEvent, error) |
| 37 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 38 | // |
| 39 | // The S33 webhook deliverer drains this. S14 only inserts; the |
| 40 | // accumulator is intentionally separate from the generic jobs table so |
| 41 | // S33 controls its own retry / batching / fan-out shape. |
| 42 | InsertWebhookEventPending(ctx context.Context, db DBTX, arg InsertWebhookEventPendingParams) (WebhookEventsPending, error) |
| 43 | // On success: clear lock + set completed_at. |
| 44 | MarkJobCompleted(ctx context.Context, db DBTX, id int64) error |
| 45 | // Terminal failure (attempts hit max). Holds locked_by NULL so the |
| 46 | // row is no longer "in flight" to dashboards; failed_at marks it |
| 47 | // visible to a future poison-job inspector (S34 admin panel). |
| 48 | MarkJobFailed(ctx context.Context, db DBTX, arg MarkJobFailedParams) error |
| 49 | MarkPushEventProcessed(ctx context.Context, db DBTX, id int64) error |
| 50 | // Delete completed jobs older than the supplied cutoff. Used by the |
| 51 | // jobs:purge_completed maintenance job. Returns the number of rows |
| 52 | // deleted so the cron handler can log progress. |
| 53 | PurgeCompletedJobs(ctx context.Context, db DBTX, completedAt pgtype.Timestamptz) (int64, error) |
| 54 | // Same as PurgeCompletedJobs but for terminally failed rows. Kept |
| 55 | // separate because operators usually want a longer retention on |
| 56 | // failures to inspect what blew up. |
| 57 | PurgeFailedJobs(ctx context.Context, db DBTX, failedAt pgtype.Timestamptz) (int64, error) |
| 58 | // Transient failure: clear the lock, record the error, push run_at |
| 59 | // forward by the caller-computed backoff. attempts was incremented |
| 60 | // by ClaimJob, so checking attempts >= max_attempts elsewhere decides |
| 61 | // between Reschedule and MarkJobFailed. |
| 62 | RescheduleJob(ctx context.Context, db DBTX, arg RescheduleJobParams) error |
| 63 | } |
| 64 | |
| 65 | var _ Querier = (*Queries)(nil) |
| 66 |