Module: CircuitSwitch
- Defined in:
- lib/circuit_switch.rb,
lib/circuit_switch/core.rb,
lib/circuit_switch/builder.rb,
lib/circuit_switch/railtie.rb,
lib/circuit_switch/version.rb,
lib/circuit_switch/notification.rb,
lib/circuit_switch/configuration.rb,
lib/circuit_switch/workers/reporter.rb,
lib/circuit_switch/stacktrace_modifier.rb,
lib/circuit_switch/workers/due_date_notifier.rb,
lib/circuit_switch/workers/run_count_updater.rb,
lib/generators/circuit_switch/install_generator.rb,
lib/generators/circuit_switch/migration_generator.rb,
lib/circuit_switch/orm/active_record/circuit_switch.rb
Defined Under Namespace
Classes: Builder, CalledNotification, CircuitSwitch, CircuitSwitchError, CircuitSwitchNotification, Configuration, Core, DueDateNotifier, InstallGenerator, MigrationGenerator, Railtie, Reporter, RunCountUpdater, StacktraceModifier
Constant Summary
collapse
- VERSION =
'0.4.1'
Class Method Summary
collapse
-
.config ⇒ Object
-
.configure {|config| ... } ⇒ Object
-
.open?(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil) ⇒ Boolean
Syntax sugar for ‘CircuitSwitch.run`.
-
.report(key: nil, if: nil, stop_report_if: nil, stop_report_if_reach_limit: nil, limit_count: nil) ⇒ Object
-
.run(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil, &block) ⇒ Object
Class Method Details
.config ⇒ Object
14
15
16
|
# File 'lib/circuit_switch.rb', line 14
def config
@config ||= Configuration.new
end
|
10
11
12
|
# File 'lib/circuit_switch.rb', line 10
def configure
yield config
end
|
.open?(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil) ⇒ Boolean
Syntax sugar for ‘CircuitSwitch.run`
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/circuit_switch.rb', line 67
def open?(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil)
if block_given?
raise ArgumentError.new('CircuitSwitch.open doesn\'t receive block. Use CircuitSwitch.run if you want to pass block.')
end
arguments = {
key: key,
if: binding.local_variable_get(:if),
close_if: close_if,
close_if_reach_limit: close_if_reach_limit,
limit_count: limit_count,
initially_closed: initially_closed,
}.reject { |_, v| v.nil? }
Builder.new.run(**arguments) {}.run?
end
|
.report(key: nil, if: nil, stop_report_if: nil, stop_report_if_reach_limit: nil, limit_count: nil) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/circuit_switch.rb', line 44
def report(key: nil, if: nil, stop_report_if: nil, stop_report_if_reach_limit: nil, limit_count: nil)
if block_given?
raise ArgumentError.new('CircuitSwitch.report doesn\'t receive block. Use CircuitSwitch.run if you want to pass block.')
end
arguments = {
key: key,
if: binding.local_variable_get(:if),
stop_report_if: stop_report_if,
stop_report_if_reach_limit: stop_report_if_reach_limit,
limit_count: limit_count
}.reject { |_, v| v.nil? }
Builder.new.report(**arguments)
end
|
.run(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil, &block) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/circuit_switch.rb', line 26
def run(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil, &block)
arguments = {
key: key,
if: binding.local_variable_get(:if),
close_if: close_if,
close_if_reach_limit: close_if_reach_limit,
limit_count: limit_count,
initially_closed: initially_closed,
}.reject { |_, v| v.nil? }
Builder.new.run(**arguments, &block)
end
|