2
我使用https://github.com/pluginaweek/state_machine引發紅寶石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以某種方式做到這一點嗎?