Class: Distribot::HandlerFinishedHandler
- Inherits:
-
Object
- Object
- Distribot::HandlerFinishedHandler
show all
- Includes:
- Handler
- Defined in:
- lib/distribot/handler_finished_handler.rb
Instance Attribute Summary
Attributes included from Handler
#consumers, #queue_name
Instance Method Summary
collapse
Methods included from Handler
handler_for, included, #initialize, queue_for
Instance Method Details
#all_phase_handler_tasks_are_complete?(flow, phase) ⇒ Boolean
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/distribot/handler_finished_handler.rb', line 18
def all_phase_handler_tasks_are_complete?(flow, phase)
redis = Distribot.redis
name = phase.name
phase.handlers
.map { |h| "distribot.flow.#{flow.id}.#{name}.#{h}.tasks" }
.map { |task_counter_key| redis.get(task_counter_key) }
.reject(&:nil?)
.select { |val| val.to_i > 0 }
.empty?
end
|
#callback(message) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/distribot/handler_finished_handler.rb', line 7
def callback(message)
flow = Distribot::Flow.find(message[:flow_id])
phase = flow.phase(message[:phase])
Distribot.publish!(
'distribot.flow.phase.finished',
flow_id: flow.id,
phase: phase.name
) if self.all_phase_handler_tasks_are_complete?(flow, phase)
end
|