Class: BlueGreenProcess::WorkerProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/blue_green_process/worker_process.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid, label, rpipe, wpipe) ⇒ WorkerProcess

Returns a new instance of WorkerProcess.



7
8
9
10
11
12
13
# File 'lib/blue_green_process/worker_process.rb', line 7

def initialize(pid, label, rpipe, wpipe)
  self.pid = pid
  self.label = label
  self.rpipe = rpipe
  self.wpipe = wpipe
  self.status = BlueGreenProcess::PROCESS_STATUS_INACTIVE
end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/blue_green_process/worker_process.rb', line 5

def label
  @label
end

#pidObject

Returns the value of attribute pid.



5
6
7
# File 'lib/blue_green_process/worker_process.rb', line 5

def pid
  @pid
end

#rpipeObject

Returns the value of attribute rpipe.



5
6
7
# File 'lib/blue_green_process/worker_process.rb', line 5

def rpipe
  @rpipe
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/blue_green_process/worker_process.rb', line 5

def status
  @status
end

#wpipeObject

Returns the value of attribute wpipe.



5
6
7
# File 'lib/blue_green_process/worker_process.rb', line 5

def wpipe
  @wpipe
end

Instance Method Details

#be_activeObject



15
16
17
18
19
20
21
# File 'lib/blue_green_process/worker_process.rb', line 15

def be_active
  return self if status == BlueGreenProcess::PROCESS_STATUS_ACTIVE

  write_and_await_until_read(BlueGreenProcess::PROCESS_COMMAND_BE_ACTIVE)
  self.status = BlueGreenProcess::PROCESS_STATUS_ACTIVE
  self
end

#be_inactiveObject



23
24
25
26
27
28
29
# File 'lib/blue_green_process/worker_process.rb', line 23

def be_inactive
  return self if status == BlueGreenProcess::PROCESS_STATUS_INACTIVE

  write_and_await_until_read(BlueGreenProcess::PROCESS_COMMAND_BE_INACTIVE)
  self.status = BlueGreenProcess::PROCESS_STATUS_INACTIVE
  self
end

#workObject



31
32
33
34
35
# File 'lib/blue_green_process/worker_process.rb', line 31

def work
  enforce_to_be_active

  write_and_await_until_read(BlueGreenProcess::PROCESS_COMMAND_WORK)
end