Skip to content

fix: allow river to use polling only#400

Merged
gusfcarvalho merged 1 commit into
mainfrom
gc-fix-river-use-polling
May 22, 2026
Merged

fix: allow river to use polling only#400
gusfcarvalho merged 1 commit into
mainfrom
gc-fix-river-use-polling

Conversation

@gusfcarvalho
Copy link
Copy Markdown
Contributor

@gusfcarvalho gusfcarvalho commented May 22, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added CCF_WORKER_USE_POLLING environment variable to enable polling-based worker behavior. Defaults to disabled, preserving existing PostgreSQL LISTEN/NOTIFY functionality.
  • Tests

    • Added unit tests verifying polling configuration defaults and behavior.

Review Change Stack

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Copilot AI review requested due to automatic review settings May 22, 2026 10:27
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 05bf1906-8243-4efc-aa26-22ae5063522e

📥 Commits

Reviewing files that changed from the base of the PR and between c83f5be and 5a6af84.

📒 Files selected for processing (6)
  • cmd/root.go
  • internal/config/config.go
  • internal/config/worker.go
  • internal/config/worker_test.go
  • internal/service/worker/service.go
  • internal/service/worker/service_test.go

📝 Walkthrough

Walkthrough

This PR adds a UsePolling configuration option to the worker service that controls whether River uses polling mode instead of PostgreSQL LISTEN/NOTIFY. The option is wired from environment variable CCF_WORKER_USE_POLLING, defaults to false, and is passed to the River client at startup.

Changes

Worker polling mode configuration

Layer / File(s) Summary
Configuration schema and defaults
internal/config/worker.go, internal/config/worker_test.go
WorkerConfig gains a UsePolling boolean field mapped from use_polling, documented with the environment variable CCF_WORKER_USE_POLLING. DefaultWorkerConfig() initializes it to false, verified by a new test.
Environment binding and config loading
cmd/root.go, internal/config/config.go
bindEnvironmentVariables() registers the worker_use_polling Viper binding, and NewConfig() conditionally reads it and wires it into the worker configuration.
River client integration and observability
internal/service/worker/service.go, internal/service/worker/service_test.go
buildRiverConfig() sets river.Config.PollOnly from cfg.UsePolling, the worker start log includes the polling mode, and tests verify the River config behavior matches the setting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A polling option joins the fray,
River workers now have their say—
LISTEN's good, but polling's fine,
Configuration makes it shine!
One flag to rule them, tested well,
Our worker dreams in harmony dwell. 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: enabling River to use polling-only mode through a new configuration option.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a worker configuration option to run River in polling-only mode (disabling PostgreSQL LISTEN/NOTIFY), allowing deployments that can’t rely on notifications to still process jobs reliably.

Changes:

  • Add UsePolling to WorkerConfig, defaulting to false, and wire it from CCF_WORKER_USE_POLLING via viper.
  • Pass UsePolling through to River via river.Config{ PollOnly: ... } and log the effective setting at startup.
  • Add unit tests covering the default and enabled behavior for the new config flag.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/service/worker/service.go Plumbs UsePolling into River config (PollOnly) and logs the setting on startup.
internal/service/worker/service_test.go Adds tests validating PollOnly default/override behavior in buildRiverConfig.
internal/config/worker.go Introduces UsePolling in WorkerConfig and sets default to false.
internal/config/worker_test.go Adds a test confirming UsePolling is disabled by default.
internal/config/config.go Reads worker_use_polling from viper into WorkerConfig.UsePolling.
cmd/root.go Binds the worker_use_polling environment variable for viper (CCF_WORKER_USE_POLLING).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gusfcarvalho gusfcarvalho merged commit 7597d41 into main May 22, 2026
6 checks passed
@gusfcarvalho gusfcarvalho deleted the gc-fix-river-use-polling branch May 22, 2026 10:44
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