Class: ExcessFlow::ThrottleConfiguration
- Inherits:
-
Object
- Object
- ExcessFlow::ThrottleConfiguration
- Defined in:
- lib/excess_flow/throttle_configuration.rb
Overview
ExcessFlow::ThrottleConfiguration
Wrapper class for throttle execution result that does provide some basic transformation of provided values.
Constant Summary collapse
- MANDATORY_KEYS =
i[ key limit ttl ].freeze
- OPTIONAL_KEYS =
i[ strategy ].freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #counter_key ⇒ Object
-
#initialize(args) ⇒ ThrottleConfiguration
constructor
A new instance of ThrottleConfiguration.
- #lock_key ⇒ Object
- #strategy ⇒ Object
Constructor Details
#initialize(args) ⇒ ThrottleConfiguration
Returns a new instance of ThrottleConfiguration.
35 36 37 38 39 40 41 42 |
# File 'lib/excess_flow/throttle_configuration.rb', line 35 def initialize(args) @raw_args = args validate_args args.each do |key, value| instance_variable_set("@#{key}", value) unless value.nil? end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
33 34 35 |
# File 'lib/excess_flow/throttle_configuration.rb', line 33 def key @key end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
33 34 35 |
# File 'lib/excess_flow/throttle_configuration.rb', line 33 def limit @limit end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
33 34 35 |
# File 'lib/excess_flow/throttle_configuration.rb', line 33 def ttl @ttl end |
Instance Method Details
#counter_key ⇒ Object
44 45 46 |
# File 'lib/excess_flow/throttle_configuration.rb', line 44 def counter_key ExcessFlow::COUNTER_PREFIX + key end |
#lock_key ⇒ Object
48 49 50 |
# File 'lib/excess_flow/throttle_configuration.rb', line 48 def lock_key ExcessFlow::LOCK_PREFIX + key end |
#strategy ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/excess_flow/throttle_configuration.rb', line 52 def strategy case @strategy when :fixed_window then ExcessFlow::FixedWindowStrategy when :sliding_window then ExcessFlow::SlidingWindowStrategy else ExcessFlow::FixedWindowStrategy end end |