在ruby状态机中触发状态之间的中间转换
我正在使用 我的代码是在ruby状态机中触发状态之间的中间转换,ruby,state-machine,transitions,Ruby,State Machine,Transitions,我正在使用 我的代码是 event :set_running do transition any => :runnning end event :restart do transition :failed => :restarting end after_transition :failed => :restarting do |job,transition| job.set_running end after_transition :restarting =&g
event :set_running do
transition any => :runnning
end
event :restart do
transition :failed => :restarting
end
after_transition :failed => :restarting do |job,transition|
job.set_running
end
after_transition :restarting => :running do |job,transition|
job.restart_servers
=begin
this takes some time. and i would like job state to be "restarting" while
it's restarting servers. but it doesn't happen (i suppose because of transaction)
until after_transition :failed => :restarting callback is finished.
so it actually doesnt happen at all because this callback triggers => :running transition
=end
end
换句话说,我想运行一次“重新启动”事件,并在它从:failed传输到:running时触发中介转换。
我可以用状态机来做吗?
现在可以禁用事务:
state_machine :initial => :parked, :use_transactions => false do