Module: Einhorn::WorkerPool
- Defined in:
- lib/einhorn/worker_pool.rb
Class Method Summary collapse
- .ack_count ⇒ Object
- .ack_target ⇒ Object
- .acked_modern_workers ⇒ Object
- .acked_modern_workers_with_state ⇒ Object
- .acked_unsignaled_modern_workers ⇒ Object
-
.missing_worker_count ⇒ Object
Use the number of modern workers, rather than unsignaled modern workers.
- .modern_workers ⇒ Object
- .modern_workers_with_state ⇒ Object
- .old_workers ⇒ Object
- .unsignaled_workers ⇒ Object
- .workers ⇒ Object
Class Method Details
.ack_count ⇒ Object
48 49 50 |
# File 'lib/einhorn/worker_pool.rb', line 48 def self.ack_count acked_unsignaled_modern_workers.length end |
.ack_target ⇒ Object
52 53 54 |
# File 'lib/einhorn/worker_pool.rb', line 52 def self.ack_target Einhorn::State.config[:number] end |
.acked_modern_workers ⇒ Object
27 28 29 |
# File 'lib/einhorn/worker_pool.rb', line 27 def self.acked_modern_workers acked_modern_workers_with_state.map {|pid, _| pid} end |
.acked_modern_workers_with_state ⇒ Object
19 20 21 |
# File 'lib/einhorn/worker_pool.rb', line 19 def self.acked_modern_workers_with_state modern_workers_with_state.select {|pid, spec| spec[:acked]} end |
.acked_unsignaled_modern_workers ⇒ Object
31 32 33 34 35 |
# File 'lib/einhorn/worker_pool.rb', line 31 def self.acked_unsignaled_modern_workers acked_modern_workers_with_state.select do |_, spec| spec[:signaled].length == 0 end.map {|pid, _| pid} end |
.missing_worker_count ⇒ Object
Use the number of modern workers, rather than unsignaled modern workers. This means if e.g. we do bunch of decs and then incs, any workers which haven’t died yet will count towards our number of workers. Since workers really should be dying shortly after they are USR2’d, that indicates a bad state and we shouldn’t make it worse by spinning up more processes. Once they die, order will be restored.
44 45 46 |
# File 'lib/einhorn/worker_pool.rb', line 44 def self.missing_worker_count ack_target - modern_workers.length end |
.modern_workers ⇒ Object
23 24 25 |
# File 'lib/einhorn/worker_pool.rb', line 23 def self.modern_workers modern_workers_with_state.map {|pid, _| pid} end |
.modern_workers_with_state ⇒ Object
13 14 15 16 17 |
# File 'lib/einhorn/worker_pool.rb', line 13 def self.modern_workers_with_state Einhorn::State.children.select do |pid, spec| spec[:version] == Einhorn::State.version end end |
.old_workers ⇒ Object
56 57 58 |
# File 'lib/einhorn/worker_pool.rb', line 56 def self.old_workers unsignaled_workers - modern_workers end |