Class: Ductwork::Processes::PipelineAdvancer

Inherits:
Object
  • Object
show all
Defined in:
lib/ductwork/processes/pipeline_advancer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#branchObject (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_atObject (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

#threadObject (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

Returns:

  • (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

#killObject



38
39
40
41
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 38

def kill
  stop
  thread&.kill
end

#nameObject



47
48
49
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 47

def name
  "ductwork.pipeline_advancer.#{klass}.#{index}"
end

#restartObject



21
22
23
24
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 21

def restart
  cleanup_dead_thread!
  start
end

#startObject



16
17
18
19
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 16

def start
  @thread = Thread.new { work_loop }
  @thread.name = name
end

#stopObject



34
35
36
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 34

def stop
  running_context.shutdown!
end

#stuck?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ductwork/processes/pipeline_advancer.rb', line 30

def stuck?
  branch.nil? && last_heartbeat_too_long_ago?
end