Class: StandardCircuit::Config
- Inherits:
-
Object
- Object
- StandardCircuit::Config
- Defined in:
- lib/standard_circuit/config.rb
Defined Under Namespace
Classes: CircuitSpec
Constant Summary collapse
- DEFAULT_THRESHOLD =
3- DEFAULT_COOL_OFF =
30- DEFAULT_WINDOW =
60- DEFAULT_CRITICALITY =
:standard- CRITICALITIES =
[ :critical, :standard, :optional ].freeze
Instance Attribute Summary collapse
-
#circuits ⇒ Object
readonly
Returns the value of attribute circuits.
-
#data_store ⇒ Object
Returns the value of attribute data_store.
-
#extra_notifiers ⇒ Object
readonly
Returns the value of attribute extra_notifiers.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#metric_prefix ⇒ Object
Returns the value of attribute metric_prefix.
-
#prefixes ⇒ Object
readonly
Returns the value of attribute prefixes.
-
#sentry_enabled ⇒ Object
Returns the value of attribute sentry_enabled.
Instance Method Summary collapse
- #add_notifier(notifier) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #notifiers ⇒ Object
- #register(name, **opts) ⇒ Object
- #register_prefix(prefix, **opts) ⇒ Object
- #reset_registry! ⇒ Object
- #spec_for(name) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
39 40 41 42 43 44 45 46 47 |
# File 'lib/standard_circuit/config.rb', line 39 def initialize @sentry_enabled = true @metric_prefix = "external" @data_store = Stoplight::DataStore::Memory.new @logger = nil @circuits = {} @prefixes = {} @extra_notifiers = [] end |
Instance Attribute Details
#circuits ⇒ Object (readonly)
Returns the value of attribute circuits.
37 38 39 |
# File 'lib/standard_circuit/config.rb', line 37 def circuits @circuits end |
#data_store ⇒ Object
Returns the value of attribute data_store.
36 37 38 |
# File 'lib/standard_circuit/config.rb', line 36 def data_store @data_store end |
#extra_notifiers ⇒ Object (readonly)
Returns the value of attribute extra_notifiers.
37 38 39 |
# File 'lib/standard_circuit/config.rb', line 37 def extra_notifiers @extra_notifiers end |
#logger ⇒ Object
Returns the value of attribute logger.
36 37 38 |
# File 'lib/standard_circuit/config.rb', line 36 def logger @logger end |
#metric_prefix ⇒ Object
Returns the value of attribute metric_prefix.
36 37 38 |
# File 'lib/standard_circuit/config.rb', line 36 def metric_prefix @metric_prefix end |
#prefixes ⇒ Object (readonly)
Returns the value of attribute prefixes.
37 38 39 |
# File 'lib/standard_circuit/config.rb', line 37 def prefixes @prefixes end |
#sentry_enabled ⇒ Object
Returns the value of attribute sentry_enabled.
36 37 38 |
# File 'lib/standard_circuit/config.rb', line 36 def sentry_enabled @sentry_enabled end |
Instance Method Details
#add_notifier(notifier) ⇒ Object
70 71 72 |
# File 'lib/standard_circuit/config.rb', line 70 def add_notifier(notifier) @extra_notifiers << notifier end |
#notifiers ⇒ Object
49 50 51 52 53 54 |
# File 'lib/standard_circuit/config.rb', line 49 def notifiers built = [ Notifiers::Logger.new(@logger) ] built << Notifiers::Sentry.new if @sentry_enabled built << Notifiers::Metrics.new(metric_prefix: @metric_prefix) built + @extra_notifiers end |
#register(name, **opts) ⇒ Object
62 63 64 |
# File 'lib/standard_circuit/config.rb', line 62 def register(name, **opts) @circuits[name.to_sym] = CircuitSpec.build(**opts) end |
#register_prefix(prefix, **opts) ⇒ Object
66 67 68 |
# File 'lib/standard_circuit/config.rb', line 66 def register_prefix(prefix, **opts) @prefixes[prefix.to_s] = CircuitSpec.build(**opts) end |
#reset_registry! ⇒ Object
56 57 58 59 60 |
# File 'lib/standard_circuit/config.rb', line 56 def reset_registry! @circuits.clear @prefixes.clear @extra_notifiers.clear end |
#spec_for(name) ⇒ Object
74 75 76 |
# File 'lib/standard_circuit/config.rb', line 74 def spec_for(name) @circuits[name.to_sym] || spec_for_prefix(name) end |