-
Notifications
You must be signed in to change notification settings - Fork 1.8k
MemoryLimiter extension as an http/grpc middleware #14071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
MemoryLimiter extension as an http/grpc middleware #14071
Conversation
d296af7 to
e5b68cf
Compare
|
@shivanthzen Thank you. This looks like a good step forward. Can we add to the memorylimiter extension README.md with an example for use? Would you add a minimal test, at least to be sure that the extension implements the middleware interface? I am not sure what internal support memorylimiter has for testing, but it would be nice to have a small test for the function itself. |
Co-authored-by: Joshua MacDonald <[email protected]>
songy23
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs make gotidy
Head branch was pushed to by a user without write access
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #14071 +/- ##
==========================================
- Coverage 92.24% 92.20% -0.04%
==========================================
Files 658 658
Lines 41168 41180 +12
==========================================
- Hits 37977 37972 -5
- Misses 2184 2199 +15
- Partials 1007 1009 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } | ||
| } | ||
|
|
||
| func TestMiddleware(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a test for this, could we use the type checker to assert interface implementation?
You could put the following above line 19 in memorylimiter.go for example:
var _ extensionmiddleware.GRPCServer = (*memoryLimiterExtension)(nil)
var _ extensionmiddleware.HTTPServer = (*memoryLimiterExtension)(nil)
Description
This PR augments the memorylimiter extension to be an HTTP/GRPC middleware. The extension can be used as an HTTP/GRPC middleware once this is merged.
Example:
Link to tracking issue
Fixes #9591
Fixes #14081
Testing
Setup a minimal collector to test that the middleware is indeed ratelimiting while the memory usage is closer to limit.
Documentation
Updated the readme for memory limiter extension.