class Dynflow::Persistence
Attributes
adapter[R]
Public Class Methods
new(world, persistence_adapter)
click to toggle source
# File lib/dynflow/persistence.rb, line 11 def initialize(world, persistence_adapter) @world = world @adapter = persistence_adapter @adapter.register_world(world) end
Public Instance Methods
delete_delayed_plans(filters, batch_size = 1000)
click to toggle source
# File lib/dynflow/persistence.rb, line 58 def delete_delayed_plans(filters, batch_size = 1000) adapter.delete_delayed_plans(filters, batch_size) end
delete_execution_plans(filters, batch_size = 1000)
click to toggle source
# File lib/dynflow/persistence.rb, line 39 def delete_execution_plans(filters, batch_size = 1000) adapter.delete_execution_plans(filters, batch_size) end
find_execution_plans(options)
click to toggle source
# File lib/dynflow/persistence.rb, line 33 def find_execution_plans(options) adapter.find_execution_plans(options).map do |execution_plan_hash| ExecutionPlan.new_from_hash(execution_plan_hash, @world) end end
find_past_delayed_plans(time)
click to toggle source
# File lib/dynflow/persistence.rb, line 52 def find_past_delayed_plans(time) adapter.find_past_delayed_plans(time).map do |plan| DelayedPlan.new_from_hash(@world, plan) end end
load_action(step)
click to toggle source
# File lib/dynflow/persistence.rb, line 17 def load_action(step) attributes = adapter. load_action(step.execution_plan_id, step.action_id). update(step: step, phase: step.phase) return Action.from_hash(attributes, step.world) end
load_action_for_presentation(execution_plan, action_id)
click to toggle source
# File lib/dynflow/persistence.rb, line 24 def load_action_for_presentation(execution_plan, action_id) attributes = adapter.load_action(execution_plan.id, action_id) Action.from_hash(attributes.update(phase: Action::Present, execution_plan: execution_plan), @world) end
load_delayed_plan(execution_plan_id)
click to toggle source
# File lib/dynflow/persistence.rb, line 66 def load_delayed_plan(execution_plan_id) hash = adapter.load_delayed_plan(execution_plan_id) return nil unless hash DelayedPlan.new_from_hash(@world, hash) end
load_execution_plan(id)
click to toggle source
# File lib/dynflow/persistence.rb, line 43 def load_execution_plan(id) execution_plan_hash = adapter.load_execution_plan(id) ExecutionPlan.new_from_hash(execution_plan_hash, @world) end
load_step(execution_plan_id, step_id, world)
click to toggle source
# File lib/dynflow/persistence.rb, line 72 def load_step(execution_plan_id, step_id, world) step_hash = adapter.load_step(execution_plan_id, step_id) ExecutionPlan::Steps::Abstract.from_hash(step_hash, execution_plan_id, world) end
pull_envelopes(world_id)
click to toggle source
# File lib/dynflow/persistence.rb, line 86 def pull_envelopes(world_id) adapter.pull_envelopes(world_id).map do |data| envelope = Dynflow.serializer.load(data) Type! envelope, Dispatcher::Envelope envelope end end
push_envelope(envelope)
click to toggle source
# File lib/dynflow/persistence.rb, line 81 def push_envelope(envelope) Type! envelope, Dispatcher::Envelope adapter.push_envelope(Dynflow.serializer.dump(envelope)) end
save_action(execution_plan_id, action)
click to toggle source
# File lib/dynflow/persistence.rb, line 29 def save_action(execution_plan_id, action) adapter.save_action(execution_plan_id, action.id, action.to_hash) end
save_delayed_plan(delayed_plan)
click to toggle source
# File lib/dynflow/persistence.rb, line 62 def save_delayed_plan(delayed_plan) adapter.save_delayed_plan(delayed_plan.execution_plan_uuid, delayed_plan.to_hash) end
save_execution_plan(execution_plan)
click to toggle source
# File lib/dynflow/persistence.rb, line 48 def save_execution_plan(execution_plan) adapter.save_execution_plan(execution_plan.id, execution_plan.to_hash) end
save_step(step)
click to toggle source
# File lib/dynflow/persistence.rb, line 77 def save_step(step) adapter.save_step(step.execution_plan_id, step.id, step.to_hash) end