-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(relay): export RateLimiter type
#3742
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
Conversation
|
Thanks for the patch! I am wondering how we can best follow the conventions laid out in #2217 with this. Currently, all the the fields on I am thinking, instead of just exposing the
This way, we don't have to expose the entire module but still allow users to use the existing configs and build their own. Does that work for your usecase? |
|
Sounds good to me @thomaseizinger |
|
Sorry for the trouble @dariusc93. I am assuming that this was my mistake back from #2059. Agreed with the suggestions above by @thomaseizinger. Thanks! @dariusc93 do you want to tackle these suggestions? |
This comment was marked as resolved.
This comment was marked as resolved.
@dariusc93 In case you missed this message, I am currently waiting on a response if the above suggestion would work for you. |
Yes it does work for me, just havent had the time to implement the suggestions myself (meant to do it this past weekend though but been busy). |
No worries (and rush) at all :) |
protocols/relay/src/behaviour.rs
Outdated
| } | ||
|
|
||
| impl Config { | ||
| pub fn per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self { |
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.
Do we want these function to be per reservation_rate_limiters and circuit_src_rate_limiters or do we want to have it so we populate both vectors per function?
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.
I am not 100% sure I follow the question. I would expect a user to want to set a different limit for reservations than for circuits, with the rational that a reservation is less expensive than a circuit. Does that make sense? I am not sure though whether we really need to support this use-case via the easy-path, instead of deferring the user to the rate-limiter primitives directly.
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.
@mxinden see #3742 (comment).
I think splitting as better as per @mxinden's reasoning. We only provide these functions to be able to hide more details from the public API. The user should still be able to make fine-grained configuration changes otherwise there is no point in providing them I think.
|
@dariusc93 Let me know when this is ready for another review or you have any questions. |
Will do! I havent forgotten about this PR and look to tackle this before this week is over. |
|
Sorry for the delay @thomaseizinger. I did push changes to split it for both |
thomaseizinger
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.
Nice, thank you for the changes!
I think this design makes sense:
- Easy things are easy: Users can call one of the pre-defined constructor functions on
Configto create several rate limiters - Hard things are possible: Users can implement their own
RateLimiterand push it to the field directly - The design is open: Users can access all values of the config.
- The API surface is minimal:
GenericRateLimiterConfigis an implementation detail
There might be an argument to not making the fields public and instead provide getter functions. Those would give us slightly more options in case we ever want to change these fields. For the moment, I am not too worried about that though.
rate-limiter modulerate-limiter module
rate-limiter moduleRateLimiter type
The `rate-limiter` module was not made publicly available. This change exports the `RateLimiter` trait defined within that module which allows users to define their own rate limiters. To make common usecases easy, we also provide a set of constructor functions for common rate limiters. Resolves #3741. Pull-Request: #3742.
Description
The
rate-limitermodule was not made publicly available. This change exports theRateLimitertrait defined within that module which allows users to define their own rate limiters. To make common usecases easy, we also provide a set of constructor functions for common rate limiters.Resolves #3741.
Notes & open questions
Change checklist