-
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
Changes from 11 commits
e463108
8691090
44e997c
3ab6ab2
1233386
c8377dc
1a09324
fcb207e
7634244
ac4dd9a
89751d7
e5279a7
48de9bd
10d52d5
6932b3f
2dc4652
d803238
d1b55b9
0c07632
98c9642
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,32 @@ pub struct Config { | |
| pub circuit_src_rate_limiters: Vec<Box<dyn rate_limiter::RateLimiter>>, | ||
| } | ||
|
|
||
| impl Config { | ||
| pub fn per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self { | ||
|
||
| self.reservation_rate_limiters | ||
| .push(rate_limiter::new_per_peer( | ||
| rate_limiter::GenericRateLimiterConfig { limit, interval }, | ||
| )); | ||
| self.circuit_src_rate_limiters | ||
| .push(rate_limiter::new_per_peer( | ||
| rate_limiter::GenericRateLimiterConfig { limit, interval }, | ||
| )); | ||
| self | ||
| } | ||
|
|
||
| pub fn per_ip(mut self, limit: NonZeroU32, interval: Duration) -> Self { | ||
| self.reservation_rate_limiters | ||
| .push(rate_limiter::new_per_ip( | ||
| rate_limiter::GenericRateLimiterConfig { limit, interval }, | ||
| )); | ||
| self.circuit_src_rate_limiters | ||
| .push(rate_limiter::new_per_ip( | ||
| rate_limiter::GenericRateLimiterConfig { limit, interval }, | ||
| )); | ||
| self | ||
| } | ||
| } | ||
|
|
||
| impl std::fmt::Debug for Config { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| f.debug_struct("Config") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.