Class: Ductwork::Processes::PipelineAdvancer
- Inherits:
-
Object
- Object
- Ductwork::Processes::PipelineAdvancer
- Defined in:
- lib/ductwork/processes/pipeline_advancer.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#last_heartbeat_at ⇒ Object
readonly
Returns the value of attribute last_heartbeat_at.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(klass, index = nil) ⇒ PipelineAdvancer
constructor
A new instance of PipelineAdvancer.
- #join(limit) ⇒ Object
- #kill ⇒ Object
- #name ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #stuck? ⇒ Boolean
Constructor Details
#initialize(klass, index = nil) ⇒ PipelineAdvancer
Returns a new instance of PipelineAdvancer.
8 9 10 11 12 13 14 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 8 def initialize(klass, index = nil) @klass = klass @index = index || 0 @running_context = Ductwork::RunningContext.new @last_heartbeat_at = Time.current @thread = nil end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
6 7 8 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 6 def branch @branch end |
#last_heartbeat_at ⇒ Object (readonly)
Returns the value of attribute last_heartbeat_at.
6 7 8 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 6 def last_heartbeat_at @last_heartbeat_at end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
6 7 8 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 6 def thread @thread end |
Instance Method Details
#alive? ⇒ Boolean
26 27 28 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 26 def alive? thread&.alive? || false end |
#join(limit) ⇒ Object
43 44 45 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 43 def join(limit) thread&.join(limit) end |
#kill ⇒ Object
38 39 40 41 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 38 def kill stop thread&.kill end |
#name ⇒ Object
47 48 49 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 47 def name "ductwork.pipeline_advancer.#{klass}.#{index}" end |
#restart ⇒ Object
21 22 23 24 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 21 def restart cleanup_dead_thread! start end |
#start ⇒ Object
16 17 18 19 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 16 def start @thread = Thread.new { work_loop } @thread.name = name end |
#stop ⇒ Object
34 35 36 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 34 def stop running_context.shutdown! end |
#stuck? ⇒ Boolean
30 31 32 |
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 30 def stuck? branch.nil? && last_heartbeat_too_long_ago? end |