class ExcessFlow::ThrottleConfiguration
ExcessFlow::ThrottleConfiguration
¶ ↑
Wrapper class for throttle execution result that does provide some basic transformation of provided values.
Constants
- MANDATORY_KEYS
- OPTIONAL_KEYS
Attributes
key[R]
limit[R]
ttl[R]
Public Class Methods
new(args)
click to toggle source
# 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
Public Instance Methods
counter_key()
click to toggle source
# File lib/excess_flow/throttle_configuration.rb, line 44 def counter_key ExcessFlow::COUNTER_PREFIX + key end
lock_key()
click to toggle source
# File lib/excess_flow/throttle_configuration.rb, line 48 def lock_key ExcessFlow::LOCK_PREFIX + key end
strategy()
click to toggle source
# 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
Private Instance Methods
allowed_keys_passed_in?()
click to toggle source
# File lib/excess_flow/throttle_configuration.rb, line 62 def allowed_keys_passed_in? (@raw_args.keys - (MANDATORY_KEYS + OPTIONAL_KEYS)).empty? end
mandatory_keys_are_present?()
click to toggle source
# File lib/excess_flow/throttle_configuration.rb, line 66 def mandatory_keys_are_present? (MANDATORY_KEYS - @raw_args.keys).empty? end
validate_args()
click to toggle source
# File lib/excess_flow/throttle_configuration.rb, line 70 def validate_args return if allowed_keys_passed_in? && mandatory_keys_are_present? raise ExcessFlow::ConfigurationError, CONFIGURATION_ERROR_MESSAGE end