Repository navigation
feat(queueing)!: queueing runs from a config, with groups of their own - #11
Closed
arjendevos wants to merge 8 commits into
Closed
arjendevos wants to merge 8 commits into
arjendevos wants to merge 8 commits into
Conversation
Every queue shared one pool of QUEUE_CONCURRENCY workers, picked by Priority: a weight, so a busy queue could take every worker and leave none for one that must not wait. A job can now say Concurrency() beside Queue(). Each queue with one gets an asynq server of its own in the same worker, with that many workers, as a Laravel Horizon supervisor; queues without one share QUEUE_CONCURRENCY by Priority as before. SIGTERM or an interrupt shuts every server down, letting jobs in flight finish. A job that names no queue goes to asynq's default queue, which the worker now always listens to: before, naming a queue on any job left those never run.
How many workers a queue gets is the queue's, not each job's: jobs on one
queue could ask for different numbers. A channel is now declared once on
the engine, engine.Channel("ci", 150), and a job is on it by naming it in
Queue(), as a Laravel Horizon supervisor in config.
A queue is only where a job waits, as in Laravel. Which workers take from
it, and how many, is a supervisor's: engine.Supervisor("ci", 150, "ci")
adds a group of 150 workers reading the ci queue, and one reading several
queues takes from them in the order given. Queues no supervisor reads
share QUEUE_CONCURRENCY by Priority, as before.
Queueing read QUEUE_DRIVER, QUEUE_CONCURRENCY and QUEUE_REDIS_CONNECTION
from the environment itself. It now runs from config.Queue, handed to
queueing.WithConfig, which it needs: without one, dispatching or working
fails with ErrNoConfig.
Workers come in groups. engine.Group("ci", ...) registers jobs on the ci
queue, whatever their Queue() says, and the config's Groups["ci"] gives
them workers of their own; every job outside a group runs on the
default queue's Concurrency, as before. A group the config gives no
workers stops the worker from starting, rather than sharing silently.
The supervisors this pull request had before are gone.
BREAKING CHANGE: queueing.WithConfig is required, NewEngine takes the
config, EngineResolver's Consume and Dispatch take the groups and the
queue, and config's queue driver type is exported as QueueDriver.
arjendevos
commented
Nov 23, 2026
| type queueDriver string | ||
| // QueueDriver is how jobs run: sync where they are dispatched, redis on | ||
| // the worker. | ||
| type QueueDriver string |
Contributor
Author
There was a problem hiding this comment.
why is this uppercase, the entire fucking idea of the config/ thing is that most things stay private
Contributor
Author
| // Groups is each queue group's workers of its own, by the name | ||
| // engine.Group registers its jobs under. A group registered without one | ||
| // stops the worker from starting. | ||
| Groups map[string]QueueGroup |
Contributor
Author
There was a problem hiding this comment.
why not call it channel and also call it engine.channel? or is that confusing with the queue() on the job itself?
Contributor
Author
There was a problem hiding this comment.
Keeping Group: "channel" reads as a Go chan, and a group is more than a queue name, it's its jobs plus workers of their own. It also stays apart from a job's Queue(), which the group overrides.
…g config error inline
A pool was a third name beside queue and group for what is one asynq server: a group's workers, or the default ones. Server says what it is, and the default one is the server with no group, so the second "default" constant goes.
Contributor
Author
|
Folded into #17. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Queueing read
QUEUE_DRIVER,QUEUE_CONCURRENCYandQUEUE_REDIS_CONNECTIONfrom the environment itself, and every queue shared one pool of workers picked byPriority: a weight, so a busy queue could take every worker and leave none for one that must not wait.Queueing now runs from
config.Queue, handed toqueueing.WithConfig, which is required. Workers come in groups, as Laravel Horizon's supervisors:Queue()says;Dispatchtakes the queue from the engine.Concurrency, byPriorityacross the queues they name, as before.Rundoes.defaultqueue, which the default workers now always read. Before, naming a queue on any job left those never run.Breaking:
queueing.WithConfigis required (an error without it),NewEnginetakes the config, andEngineResolver'sConsumeandDispatchtake the groups and the queue. The queue driver type stays private: read it withenv.Enum("QUEUE_DRIVER", config.SynchronousQueueDriver). To upgrade, pass aconfig.Queuewith the driver and concurrency the environment used to give.Tested:
tests/queueingcovers the required config, unknown drivers, a group's queue, and how jobs and groups become the worker's asynq servers (one per group, one for the rest), including the refusals. A run against a real Redis gave the default queue 2 workers with 6 blocking jobs queued; a job in acigroup of 1 worker still ran at once.