Create a gist now

Instantly share code, notes, and snippets.

anonymous /a.rb
Created Jul 22, 2010

require 'rubygems'
require 'yajl'
require 'ruote'
engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new))
pdef = Ruote.define do
sequence do
alpha
bravo
zebulon
end
end
class ThisParticipant
include Ruote::LocalParticipant
def consume (workitem)
puts "* #{workitem.participant_name}"
reply_to_engine(workitem)
end
end
class ThatParticipant
include Ruote::LocalParticipant
def consume (workitem)
puts ". #{workitem.participant_name}"
# no reply to engine
end
def cancel (fei, flavour)
# ok, let pass
end
def do_not_thread; true; end
end
engine.register_participant 'alpha', ThisParticipant
engine.register_participant 'bravo', ThisParticipant
engine.register_participant 'charlie', ThisParticipant
engine.register_participant 'zebulon', ThatParticipant
#engine.context.logger.noisy = true
wfid = engine.launch(pdef)
engine.wait_for(:zebulon)
ps = engine.process(wfid)
sequence = ps.expressions.find { |fexp| fexp.fei.expid == '0_0' }
puts "re_applying..."
engine.re_apply(sequence.fei, :tree => Ruote.to_tree do
sequence do
charlie
bravo
alpha
end
end)
engine.wait_for(wfid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment