Class: Dynflow::Director::EventWorkItem

Inherits:
StepWorkItem show all
Defined in:
lib/dynflow/director.rb

Constant Summary

Constants inherited from Serializable

Serializable::LEGACY_TIME_FORMAT, Serializable::TIME_FORMAT

Instance Attribute Summary collapse

Attributes inherited from StepWorkItem

#step

Attributes inherited from WorkItem

#execution_plan_id, #queue, #sender_orchestrator_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WorkItem

#world, #world=

Methods inherited from Serializable

constantize, from_hash

Constructor Details

#initialize(request_id, execution_plan_id, step, event, queue, sender_orchestrator_id) ⇒ EventWorkItem

Returns a new instance of EventWorkItem.



87
88
89
90
91
# File 'lib/dynflow/director.rb', line 87

def initialize(request_id, execution_plan_id, step, event, queue, sender_orchestrator_id)
  super(execution_plan_id, step, queue, sender_orchestrator_id)
  @event = event
  @request_id = request_id
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



85
86
87
# File 'lib/dynflow/director.rb', line 85

def event
  @event
end

#request_idObject (readonly)

Returns the value of attribute request_id.



85
86
87
# File 'lib/dynflow/director.rb', line 85

def request_id
  @request_id
end

Class Method Details

.new_from_hash(hash, *_args) ⇒ Object



101
102
103
104
105
106
107
108
# File 'lib/dynflow/director.rb', line 101

def self.new_from_hash(hash, *_args)
  self.new(hash[:request_id],
           hash[:execution_plan_id],
           Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world),
           Dynflow.serializer.load(hash[:event]),
           hash[:queue],
           hash[:sender_orchestrator_id])
end

Instance Method Details

#executeObject



93
94
95
# File 'lib/dynflow/director.rb', line 93

def execute
  @step.execute(@event)
end

#to_hashObject



97
98
99
# File 'lib/dynflow/director.rb', line 97

def to_hash
  super.merge(request_id: @request_id, event: Dynflow.serializer.dump(@event))
end