Module: SpeedLimiter
- Defined in:
- lib/speed_limiter.rb,
lib/speed_limiter/redis.rb,
lib/speed_limiter/state.rb,
lib/speed_limiter/config.rb,
lib/speed_limiter/version.rb,
lib/speed_limiter/throttle.rb,
lib/speed_limiter/throttle_params.rb,
lib/speed_limiter/errors/throttled_error.rb,
lib/speed_limiter/errors/limit_exceeded_error.rb
Overview
Call speed limiter
Defined Under Namespace
Modules: Errors Classes: Config, Redis, State, Throttle, ThrottleParams
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.throttle(key, **params) {|state| ... } ⇒ Object
Return value of block if argument contains block, otherwise Throttle instance.
Class Method Details
.config ⇒ Object
11 12 13 |
# File 'lib/speed_limiter.rb', line 11 def config @config ||= Config.new end |
.configure {|config| ... } ⇒ Object
15 16 17 |
# File 'lib/speed_limiter.rb', line 15 def configure yield(config) end |
.throttle(key, **params) {|state| ... } ⇒ Object
Return value of block if argument contains block, otherwise Throttle instance
24 25 26 27 28 29 30 31 32 |
# File 'lib/speed_limiter.rb', line 24 def throttle(key, **params, &block) throttle = Throttle.new(key, config: config, **params) if block throttle.call(&block) else throttle end end |