Skip to content

test: add multi-queue worker coverage (framework#1564) - #153

Merged
hwbrzzl merged 2 commits into
masterfrom
test-pr-1564-multi-queue-worker
Sep 25, 2026
Merged

hwbrzzl merged 2 commits into
masterfrom
test-pr-1564-multi-queue-worker

Conversation

@goravel-agent

@goravel-agent goravel-agent commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A worker started with a queue list ("high,default") now drains higher-priority queues first regardless of dispatch order, and a no-args Worker() consumes the configured queue.connections.*.queue list.
  • Dispatching without OnQueue() targets the first name in the configured list instead of the raw combined string, and failed jobs record the queue they were reserved from.
  • Queue lists are normalized before use: surrounding whitespace is trimmed, empty entries are skipped, and a whitespace-only list falls back to default.

Why

Framework#1564 adds support for multiple queues in the worker: a worker accepts a comma-separated queue list and polls it left to right as a priority order, and a queue connection can declare more than one queue name. This branch upgrades the example to a build carrying #1564 and adds an integration suite so the example stays a faithful, executable reference for the new semantics. With #1564 merged, go.mod now tracks upstream github.com/goravel/framework at the latest master (v1.18.1-0.20260925114822-dab1968caa54) and go.sum was regenerated with go mod tidy; the replace directive is kept but repointed from the temporary fork to upstream.

// config/queue.go: a connection may now list several queues, polled left to
// right, so "high" is always served before "default".
"database": map[string]any{
	"driver":      "database",
	"connection":  "sqlite",
	"queue":       "high,default",
	"concurrent":  5,
	"retry_after": 60,
},

// Dispatch a job onto a named queue.
facades.Queue().Job(&jobs.Test{}, []contractsqueue.Arg{
	{Type: "string", Value: "user@example.com"},
}).OnQueue("high").Dispatch()

// A worker drains the whole list in priority order; Worker() with no args
// reads queue.connections.<connection>.queue automatically.
worker := facades.Queue().Worker(contractsqueue.Args{
	Connection: "database",
	Queue:      "high,default",
	Concurrent: 1,
})
go worker.Run()
defer worker.Shutdown()

QueueMultiQueueTestSuite locks the behavior in end to end: priority polling is proven to follow the queue list rather than insertion order, no-args Worker() proves the configured list is consumed, default dispatch proves the first configured queue is targeted, failed jobs prove their reserved queue is attributed, and the normalization cases cover trim, empty-entry, and empty-list fallback.

@goravel-agent
goravel-agent requested a review from a team as a code owner September 25, 2026 09:25
@hwbrzzl
hwbrzzl force-pushed the test-pr-1564-multi-queue-worker branch from fed9afc to be17d07 Compare September 25, 2026 11:26
@hwbrzzl
hwbrzzl enabled auto-merge (squash) September 25, 2026 12:05
@hwbrzzl
hwbrzzl merged commit ef8ee7b into master Sep 25, 2026
9 checks passed
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.

2 participants