Open
Conversation
Key changes: - XREADGROUP BLOCK replaces non-blocking reads - Interleaved PEL processing via XAUTOCLAIM with configurable ratio_slice - PEL stall detection: compares size across full traversals, advances ratio_slice and pel_wait_slice indices when stalled, resets on progress - Adaptive backoff (backoff_slice) when both phases return empty - Context-aware sleeps for clean shutdown - Config validation in InitConsumer (fail-fast before any network call) - New: Stats(), DefaultConsumerName(), ConsumerStats type - Remove: PendingMessages(), exported NewMessages()/AutoClaimMessages() - Add ErrInvalidConfig to errors package - 44 unit tests, all passing
There was a problem hiding this comment.
Pull request overview
This PR introduces an adaptive Redis Streams consumer loop that interleaves blocking XREADGROUP reads with periodic PEL processing via XAUTOCLAIM, adds stall detection/backoff behavior, and bumps the module major version to v4 with updated dependencies, documentation, and CI.
Changes:
- Reworked consumer internals: blocking reads (
BLOCK), interleaved PEL processing, stall detection, adaptive backoff, and context-aware sleeps. - Added config validation (fail-fast), new error (
ErrInvalidConfig), plus observability helpers (Stats(),ConsumerStats) andDefaultConsumerName(). - Migrated module/import paths to
github.com/enerBit/redsumer/v4, updated dependencies, tests, README, and CI.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/producer/producer_test.go | Updates imports to v4 and removes now-unused constants. |
| pkg/producer/producer.go | Updates client import path to v4. |
| pkg/errors/error.go | Adds ErrInvalidConfig and aligns error var formatting. |
| pkg/consumer/consumer_test.go | Adds extensive unit tests covering new consumer behavior and helpers. |
| pkg/consumer/consumer.go | Implements the new adaptive consume loop, config validation, stats, and default consumer naming. |
| pkg/client/client_test.go | Updates test to avoid network usage by injecting a mock client. |
| pkg/client/client.go | Allows injecting a pre-built/mocked Valkey client by short-circuiting InitClient when Instance is set. |
| go.mod | Bumps module to /v4, updates Go version and dependency versions. |
| go.sum | Updates dependency checksums in line with go.mod changes. |
| README.md | Rewrites docs to describe the new adaptive consumer behavior and v4 usage. |
| .github/workflows/CI.yaml | Updates Go version and test commands. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+141
to
+144
| if err := c.exist(ctx, c.StreamName); err == nil { | ||
| return nil | ||
| } | ||
| time.Sleep(time.Second * time.Duration(waitTime)) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Key changes:
ratio_slice and pel_wait_slice indices when stalled, resets on progress