Class: Rcb::DSL::ConfigBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rcb/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag) ⇒ ConfigBuilder

Returns a new instance of ConfigBuilder.



52
53
54
55
56
# File 'lib/rcb/configuration.rb', line 52

def initialize(tag)
  @tag = tag
  @open_condition_builder = OpenConditionBuilder.new
  @reset_timeout_msec = nil
end

Instance Method Details

#buildObject



71
72
73
74
75
76
77
# File 'lib/rcb/configuration.rb', line 71

def build
  Rcb::Config.create(
    @tag,
    open_condition: @open_condition_builder.build,
    reset_timeout_msec: @reset_timeout_msec
  ).freeze
end

#open_condition(hash = nil) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/rcb/configuration.rb', line 58

def open_condition(hash = nil)
  if hash
    @open_condition_builder.max_failure_count hash[:max_failure_count]
    @open_condition_builder.window_msec hash[:window_msec]
  else
    @open_condition_builder
  end
end

#reset_timeout_msec(msec) ⇒ Object



67
68
69
# File 'lib/rcb/configuration.rb', line 67

def reset_timeout_msec(msec)
  @reset_timeout_msec = msec
end