Module: Rollgeist::ExecutionState
- Defined in:
- lib/rollgeist/execution_state.rb
Defined Under Namespace
Classes: Counter, Decision
Constant Summary
collapse
- COUNTER_KEY =
:__rollgeist_execution_counter
- FALLBACK_WINDOW_SECONDS =
60
Class Method Summary
collapse
Class Method Details
.claim(limit) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/rollgeist/execution_state.rb', line 32
def claim(limit)
counter = ActiveSupport::IsolatedExecutionState[COUNTER_KEY]
return claim_from(counter, limit) if counter
fallback_claim(limit)
end
|
.complete! ⇒ Object
26
27
28
29
30
|
# File 'lib/rollgeist/execution_state.rb', line 26
def complete!
counter = ActiveSupport::IsolatedExecutionState[COUNTER_KEY]
ActiveSupport::IsolatedExecutionState[COUNTER_KEY] = nil
Notifier.report_suppressed(counter.suppressed) if counter&.suppressed.to_i.positive?
end
|
.install!(executor = ActiveSupport::Executor) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/rollgeist/execution_state.rb', line 13
def install!(executor = ActiveSupport::Executor)
@installed_executors ||= {}
return if @installed_executors[executor.object_id]
executor.to_run { Rollgeist::ExecutionState.start! }
executor.to_complete { Rollgeist::ExecutionState.complete! }
@installed_executors[executor.object_id] = true
end
|
.reset! ⇒ Object
39
40
41
42
|
# File 'lib/rollgeist/execution_state.rb', line 39
def reset!
ActiveSupport::IsolatedExecutionState[COUNTER_KEY] = nil
fallback_mutex.synchronize { @fallback_counter = new_counter }
end
|
.start! ⇒ Object
22
23
24
|
# File 'lib/rollgeist/execution_state.rb', line 22
def start!
ActiveSupport::IsolatedExecutionState[COUNTER_KEY] = new_counter
end
|