Skip to content

feat: [#949] make queue worker receive timeout configurable - #1568

Merged
hwbrzzl merged 2 commits into
masterfrom
bowen/949-queue-timeout
Oct 4, 2026
Merged

hwbrzzl merged 2 commits into
masterfrom
bowen/949-queue-timeout

Conversation

@goravel-coder

Copy link
Copy Markdown
Contributor

Summary

  • Queue workers now bound each blocking Receive call by the per-connection queue.connections.<connection>.timeout setting, replacing the hardcoded 5-second receive deadline.
  • The timeout accepts integer or fractional seconds, numeric strings, json.Number and duration strings such as "5s"; missing, non-positive, NaN or overflowing values fall back to the exported DefaultReceiveTimeout (5s).
  • Extend the queue Config contract with Timeout(connection string) time.Duration, regenerate mocks/queue/Config.go, and ship "timeout": 5 on the scaffold database connection.

Closes goravel/goravel#949

Why

The worker's receive loop used a hardcoded 5*time.Second deadline per Receive call (with a TODO make the timeout configurable). Receive-based drivers such as Redis Streams or Kafka could not tune how long a single blocking receive may wait, so this change exposes a per-connection timeout while keeping 5 seconds as the default.

Set it in config/queue.go alongside the other connection options; the scaffold database connection now includes it as a starting point.

// config/queue.go
"connections": map[string]any{
    "redis": map[string]any{
        "driver":     "redis",
        "connection": "default",
        "queue":      "default",
        "concurrent": 1,
        "timeout":    10, // seconds a single blocking receive may wait; defaults to 5
    },
},

Unlike the original PR #1553 description, this change does update public contracts: Timeout(connection string) time.Duration is added to contracts/queue/config.go and mocks/queue/Config.go is regenerated by mockery. It also fixes the compile failure from that PR, where queue/worker.go referenced a non-existent r.queueName instead of the local queueName, and a gofmt violation in queue/config.go.

@goravel-coder
goravel-coder requested a review from a team as a code owner October 3, 2026 03:54
@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.87%. Comparing base (bbc3497) to head (11d7b30).

Files with missing lines Patch % Lines
queue/setup/stubs.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1568      +/-   ##
==========================================
+ Coverage   72.84%   72.87%   +0.03%     
==========================================
  Files         412      412              
  Lines       26846    26880      +34     
==========================================
+ Hits        19556    19589      +33     
- Misses       7288     7289       +1     
  Partials        2        2              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread queue/setup/stubs.go Outdated
Comment thread queue/setup/stubs.go Outdated
@hwbrzzl
hwbrzzl merged commit fb354e7 into master Oct 4, 2026
21 checks passed
@hwbrzzl
hwbrzzl deleted the bowen/949-queue-timeout branch October 4, 2026 01:25
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.

Can Timeout be configured? We may add it to Pop and Push as well, we can create a new issue for it first.

2 participants