我正在使用https://github.com/pluginaweek/state_machine
我的代码是
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
换句话说,我想运行一次“重启”事件并在它从:失败转移到:运行时触发中间转换。我可以使用 state_machine 以某种方式做到这一点吗?