Skip to content

Instantly share code, notes, and snippets.

/a.rb

Created July 22, 2010 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/485559 to your computer and use it in GitHub Desktop.
Save anonymous/485559 to your computer and use it in GitHub Desktop.
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