Class: CircuitBreaker::Token::StateConfigDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/circuit_breaker/token.rb

Overview

DSL for state configuration

Instance Method Summary collapse

Constructor Details

#initialize(token_class) ⇒ StateConfigDSL

Returns a new instance of StateConfigDSL.



167
168
169
# File 'lib/circuit_breaker/token.rb', line 167

def initialize(token_class)
  @token_class = token_class
end

Instance Method Details

#on_states(states, timestamps:) ⇒ Object



175
176
177
178
179
# File 'lib/circuit_breaker/token.rb', line 175

def on_states(states, timestamps:)
  Array(timestamps).each do |timestamp|
    @token_class.track_timestamp(timestamp, on_states: states)
  end
end

#state(name, timestamps: nil, message: nil, &block) ⇒ Object



171
172
173
# File 'lib/circuit_breaker/token.rb', line 171

def state(name, timestamps: nil, message: nil, &block)
  @token_class.state_config(name, timestamps: timestamps, message: message, &block)
end