Skip to content

Fix client.connection_rate_limit refilling at 1 req/sec - #1207

Merged
FZambia merged 1 commit into
centrifugal:masterfrom
moses-mbaga:codex/fix-connection-rate-limit
Aug 18, 2026
Merged

Fix client.connection_rate_limit refilling at 1 req/sec#1207
FZambia merged 1 commit into
centrifugal:masterfrom
moses-mbaga:codex/fix-connection-rate-limit

Conversation

@moses-mbaga

Copy link
Copy Markdown
Contributor

Proposed changes

  • Use client.connection_rate_limit as the token bucket's sustained per-second rate.
  • Preserve the configured value as the burst size.
  • Extend the existing connection-limit middleware test to assert both values.

The limiter currently uses rate.Every(time.Second), which always refills at one request per second regardless of the configured limit. Converting the configured integer to rate.Limit makes the sustained rate match the documented behavior.

Validation

  • go test -race ./internal/middleware -count=1
  • go build ./...
  • golangci-lint run --timeout 10m0s with the repository-pinned v2.11.1

Fixes #1206

- Use the configured connection limit as the token bucket's sustained per-second rate.
- Preserve the configured burst size.
- Assert the sustained rate and burst in the existing middleware regression test.
@moses-mbaga
moses-mbaga marked this pull request as ready for review August 18, 2026 16:13
@FZambia FZambia changed the title Fix client connection rate limit Fix client.connection_rate_limit refilling at 1 req/sec Aug 18, 2026
@FZambia

FZambia commented Aug 18, 2026

Copy link
Copy Markdown
Member

Hi @moses-mbaga

Many thanks for the report and the fix!

@FZambia
FZambia merged commit 9a5110c into centrifugal:master Aug 18, 2026
2 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.

[bug] client.connection_rate_limit refills at 1 request/second regardless of configured value

2 participants