Skip to content

feat(queueing)!: give queue groups workers of their own - #17

Merged
arjendevos merged 1 commit into
mainfrom
feat/queue-groups
Nov 23, 2026
Merged

arjendevos merged 1 commit into
mainfrom
feat/queue-groups

Conversation

@arjendevos

Copy link
Copy Markdown
Contributor

Every job shared one set of workers, so a burst of jobs (mail, background work) could hold up the ones that must start at once.

// config
config.Queue{
	Driver:      config.RedisQueueDriver,
	Concurrency: 100, // every job outside a group
	Groups: map[string]config.QueueGroup{
		"ci": {Concurrency: 150, CheckInterval: 100 * time.Millisecond},
	},
}

// routes
engine.Group("ci", func(group *queueing.Group) {
	group.Job(new(LaunchRunnerJob))
})
engine.Job(new(SendWelcomeJob))
  • Each group runs on an asynq server of its own, reading only the group's queue. Jobs outside a group share the default workers, picking between their Queue() by Priority() as before.
  • The worker refuses to start for a group without workers in the config, or for a job outside a group that uses a group's queue.
  • CheckInterval lets a set of workers poll an idle queue more often than asynq's 1s default.
  • Queueing runs from config.Queue via queueing.WithConfig (required) instead of QUEUE_* environment variables.

Breaking: pass queueing.WithConfig; NewEngine takes the config; EngineResolver.Consume and Dispatch take the groups and the queue.

Tested: tests/queueing covers the config, the queue a job is dispatched to, and how jobs and groups become servers, including the refusals. Against a real Redis, a job in a group with 1 worker started at once while the 2 default workers were busy with 6 jobs queued.

Replaces #11 and #16.

Every job shared one set of workers, so a burst of jobs could hold up the
ones that must start at once. engine.Group registers jobs that run on an
asynq server of their own, sized by config.Queue.Groups, while every other
job keeps sharing the default workers by Queue() and Priority().

The queue now runs from config.Queue, passed with queueing.WithConfig, which
is required, instead of reading QUEUE_* environment variables. Each set of
workers can also poll an idle queue more often than asynq's 1s default
(CheckInterval), so a job dispatched to an idle group starts sooner.

BREAKING CHANGE: queueing needs queueing.WithConfig, NewEngine takes the
config, and EngineResolver's Consume and Dispatch take the groups and the
queue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant