File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
lib/aikido/zen/rate_limiter Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,15 @@ class RateLimiter::Bucket
2929 # @!visibility private
3030 #
3131 # Use the monotonic clock to ensure time differences are consistent
32- # and not affected by timezones. or daylight savings changes.
32+ # and not affected by timezones or daylight savings changes.
3333 DEFAULT_CLOCK = -> { Process . clock_gettime ( Process ::CLOCK_MONOTONIC ) . round }
3434
35+ # @param ttl [Integer] the time to live in seconds
36+ # @param max_size [Integer] the number of requests before throttling
37+ # @param clock [#call() => Integer] a callable that returns the current
38+ # monotonic time in seconds
39+ # @param settings [Aikido::Zen::RuntimeSettings::RateLimitSettings, nil]
40+ # the settings that might change
3541 def initialize ( ttl :, max_size :, clock : DEFAULT_CLOCK , settings : nil )
3642 @ttl = ttl
3743 @max_size = max_size
@@ -68,10 +74,13 @@ def increment(key)
6874 end
6975 end
7076
77+ # Checks whether the settings provided at initialization have changed.
78+ #
79+ # @param settings [Aikido::Zen::RuntimeSettings::RateLimitSettings]
80+ # @return [Boolean] true if settings were provided at initialization and
81+ # the settings have changed
7182 def settings_changed? ( settings )
72- return false if @settings . nil?
73-
74- @settings != settings
83+ !@settings . nil? && @settings != settings
7584 end
7685
7786 private
You can’t perform that action at this time.
0 commit comments