Skip to content

Simplify StreamRateLimiter and make its stats more flexible#44145

Merged
ravenblackx merged 1 commit intoenvoyproxy:mainfrom
ravenblackx:stream_rate_limiter
Mar 31, 2026
Merged

Simplify StreamRateLimiter and make its stats more flexible#44145
ravenblackx merged 1 commit intoenvoyproxy:mainfrom
ravenblackx:stream_rate_limiter

Conversation

@ravenblackx
Copy link
Copy Markdown
Contributor

@ravenblackx ravenblackx commented Mar 27, 2026

Commit Message: Simplify StreamRateLimiter and make its stats more flexible
Additional Description: The constructor of StreamRateLimiter only conditionally uses two of its mandatory input arguments (if a TokenBucket is provided those args are ignored). Instead of doing that, it makes more sense to have the TokenBucket be mandatory, and provide a helper function to convert those other two args into a TokenBucket argument - that way clients that want to use the TokenBucket method aren't forced to provide those unused args.

And the stats callback of StreamRateLimiter exposes "there is stuff in the buffer" where it's just as easy to provide "there is this much stuff in the buffer" - doing the latter allows the client to construct more valuable stats.

A test setup function that was never called was also removed.
Risk Level: Very low - existing behavior is effectively unchanged. (External extensions using StreamRateLimiter will need to update to the new API.)
Testing: Existing test coverage covers this just as well as it did the old version.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Raven Black <ravenblack@dropbox.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #44145 was opened by ravenblackx.

see: more, trace.

@ravenblackx ravenblackx marked this pull request as ready for review March 27, 2026 19:19
@ravenblackx
Copy link
Copy Markdown
Contributor Author

Picking @tonya11en to review since you helped me simplify the fair token bucket and this is going to be part of the same thing. (Mostly I just wanted the more usable stats, but the clunky constructor kept bothering me as well.)

@ravenblackx
Copy link
Copy Markdown
Contributor Author

/retest

@ravenblackx ravenblackx merged commit 23a318f into envoyproxy:main Mar 31, 2026
29 checks passed
@ravenblackx ravenblackx deleted the stream_rate_limiter branch March 31, 2026 18:35
TAOXUY pushed a commit to TAOXUY/envoy that referenced this pull request Apr 1, 2026
…xy#44145)

Commit Message: Simplify StreamRateLimiter and make its stats more
flexible
Additional Description: The constructor of StreamRateLimiter only
conditionally uses two of its mandatory input arguments (if a
TokenBucket is provided those args are ignored). Instead of doing that,
it makes more sense to have the TokenBucket be mandatory, and provide a
helper function to convert those other two args into a TokenBucket
argument - that way clients that want to use the TokenBucket method
aren't forced to provide those unused args.

And the stats callback of StreamRateLimiter exposes "there is stuff in
the buffer" where it's just as easy to provide "there is this much stuff
in the buffer" - doing the latter allows the client to construct more
valuable stats.

A test setup function that was never called was also removed.
Risk Level: Very low - existing behavior is effectively unchanged.
(External extensions using StreamRateLimiter will need to update to the
new API.)
Testing: Existing test coverage covers this just as well as it did the
old version.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
nshipilov pushed a commit to nshipilov/envoy that referenced this pull request Apr 13, 2026
…xy#44145)

Commit Message: Simplify StreamRateLimiter and make its stats more
flexible
Additional Description: The constructor of StreamRateLimiter only
conditionally uses two of its mandatory input arguments (if a
TokenBucket is provided those args are ignored). Instead of doing that,
it makes more sense to have the TokenBucket be mandatory, and provide a
helper function to convert those other two args into a TokenBucket
argument - that way clients that want to use the TokenBucket method
aren't forced to provide those unused args.

And the stats callback of StreamRateLimiter exposes "there is stuff in
the buffer" where it's just as easy to provide "there is this much stuff
in the buffer" - doing the latter allows the client to construct more
valuable stats.

A test setup function that was never called was also removed.
Risk Level: Very low - existing behavior is effectively unchanged.
(External extensions using StreamRateLimiter will need to update to the
new API.)
Testing: Existing test coverage covers this just as well as it did the
old version.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Nick Shipilov <nick.shipilov.n@gmail.com>
phlax pushed a commit that referenced this pull request Apr 13, 2026
Relnote to accompany the change made in #44145, in case of external filters using the API.

Signed-off-by: Raven Black <ravenblack@dropbox.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
…xy#44145)

Commit Message: Simplify StreamRateLimiter and make its stats more
flexible
Additional Description: The constructor of StreamRateLimiter only
conditionally uses two of its mandatory input arguments (if a
TokenBucket is provided those args are ignored). Instead of doing that,
it makes more sense to have the TokenBucket be mandatory, and provide a
helper function to convert those other two args into a TokenBucket
argument - that way clients that want to use the TokenBucket method
aren't forced to provide those unused args.

And the stats callback of StreamRateLimiter exposes "there is stuff in
the buffer" where it's just as easy to provide "there is this much stuff
in the buffer" - doing the latter allows the client to construct more
valuable stats.

A test setup function that was never called was also removed.
Risk Level: Very low - existing behavior is effectively unchanged.
(External extensions using StreamRateLimiter will need to update to the
new API.)
Testing: Existing test coverage covers this just as well as it did the
old version.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Raven Black <ravenblack@dropbox.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
Relnote to accompany the change made in envoyproxy#44145, in case of external filters using the API.

Signed-off-by: Raven Black <ravenblack@dropbox.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