feat(13-01): queue jobs whose worker ships later while a worker runs
- a kind no plugin registered always inserts through the insert-only River client, so Dispatch and Enqueue no longer fail River's unknown-kind check while the in-process worker runs - while a worker runs, such a kind must name a queue no worker serves; an empty queue, default, scheduled, a configured queue or a registered job's queue is ErrUnregisteredKindQueue and nothing is written - README and docs/services/jobs.md describe jobs whose worker ships later
This commit is contained in:
@@ -93,6 +93,14 @@ return id, err
|
||||
|
||||
For fire-and-forget work that needs no row, `conga.Manager.Enqueue` inserts the job alone, inside the caller's transaction when there is one.
|
||||
|
||||
## Jobs whose worker ships later
|
||||
|
||||
Sometimes a request must queue a job before the release that runs it exists: the port of a feature ships its endpoints first and the background work in a later release. Dispatch such a job onto a queue that nothing serves yet. The request's transaction writes the `summer_jobs` row and the queued job as usual, and the job waits, unworked, until a release registers its worker and adds its queue to the served set. Status pages that read the row report it in progress, as the WinterCMS job manager does before its worker picks a job up.
|
||||
|
||||
A kind that no plugin registers is always inserted through a client that does not check kinds, so the insert succeeds even while the in-process worker runs. While a worker runs, conga also refuses such a job with `conga.ErrUnregisteredKindQueue` when it names no queue, or names a queue a worker serves: `default`, `scheduled`, a queue in `queue.queues` or a queue a registered job names. A worker would fetch the job from such a queue, find no worker for its kind and discard it after its attempts. Nothing is written when the dispatch is refused.
|
||||
|
||||
Keep such a queue out of `queue.queues` until its worker ships. Queue names use lowercase letters and digits separated by `_` or `-`, so a dotted name belongs in the row's `Label`, not in its queue. `conga.Manager.CancelJob` works on a waiting job like on any other.
|
||||
|
||||
## The summer_jobs record
|
||||
|
||||
The `summer_jobs` row is what the application reads to show progress. `conga.Manager.Get` returns it as a `conga.Record`, and its `conga.Record.Status` holds the WinterCMS job statuses:
|
||||
|
||||
Reference in New Issue
Block a user