запуск промежуточного перехода между состояниями в ruby ​​state_machine

я использую 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

Другими словами, я хотел бы запустить событие «перезагрузка» один раз и вызвать промежуточный переход, пока он переходит из :failed в :running. Могу ли я сделать это как-то с помощью state_machine?


person Pavel K.    schedule 17.01.2013    source источник


Ответы (1)


http://rdoc.info/github/pluginaweek/state_machine/master/StateMachine/Integrations/ActiveRecord

Теперь можно отключить транзакции:

state_machine :initial => :parked, :use_transactions => false do
person Pavel K.    schedule 26.11.2013