Skip to content

Pel protection backoff#24

Open
santi-giraldo2 wants to merge 7 commits intoenerBit:mainfrom
santi-giraldo2:pel-protection-backoff
Open

Pel protection backoff#24
santi-giraldo2 wants to merge 7 commits intoenerBit:mainfrom
santi-giraldo2:pel-protection-backoff

Conversation

@santi-giraldo2
Copy link
Contributor

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

santi-giraldo2 and others added 6 commits September 9, 2024 12:25
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
Copy link

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 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) and DefaultConsumerName().
  • 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>
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