Module: CircuitSwitch
- Defined in:
- lib/circuit_switch.rb,
lib/circuit_switch/core.rb,
lib/circuit_switch/engine.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,
app/controllers/circuit_switch/application_controller.rb,
app/controllers/circuit_switch/circuit_switch_controller.rb
Defined Under Namespace
Classes: ApplicationController, Builder, CalledNotification, CircuitSwitch, CircuitSwitchController, CircuitSwitchError, CircuitSwitchNotification, Configuration, Core, DueDateNotifier, Engine, InstallGenerator, MigrationGenerator, Railtie, Reporter, RunCountUpdater, StacktraceModifier
Constant Summary
collapse
- VERSION =
'0.5.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
-
.table_name_prefix ⇒ Object
Class Method Details
.config ⇒ Object
15
16
17
|
# File 'lib/circuit_switch.rb', line 15
def config
@config ||= Configuration.new
end
|
11
12
13
|
# File 'lib/circuit_switch.rb', line 11
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`
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/circuit_switch.rb', line 68
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/circuit_switch.rb', line 45
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
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/circuit_switch.rb', line 27
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
|
.table_name_prefix ⇒ Object
2
3
4
|
# File 'lib/circuit_switch/engine.rb', line 2
def self.table_name_prefix
''
end
|