Sha256: b62b85f15758c13f750bb1b5348007006a22369d147877203aea7ca2f34237c7
Contents?: true
Size: 1.45 KB
Versions: 60
Compression:
Stored size: 1.45 KB
Contents
module CapistranoMulticonfigParallel # class that handles the states of the celluloid worker executing the child process in a fork process class StateMachine include ComposableStateMachine::CallbackRunner attr_accessor :job, :actor, :initial_state, :state def initialize(job, actor) @job = job @actor = actor @initial_state = @job.status machine end def go_to_transition(action) transitions.on(action, state.to_s => action) @job.status = action machine.trigger(action) end def machine @machine ||= ComposableStateMachine::MachineWithExternalState.new( model, method(:state), method(:state=), state: @initial_state.to_s, callback_runner: self) @machine end def transitions @transitions ||= ComposableStateMachine::Transitions.new @transitions end def model ComposableStateMachine.model( transitions: transitions, behaviors: { enter: { any: proc do |current_state, event, new_state| actor_notify_state_change(current_state, event, new_state) end } }, initial_state: @initial_state ) end private def actor_notify_state_change(current_state, event, new_state) @actor.send_msg(CapistranoMulticonfigParallel::TerminalTable.topic, type: 'event', message: "Going from #{current_state} to #{new_state} due to a #{event} event") end end end
Version data entries
60 entries across 60 versions & 1 rubygems