Skip to content

Instantly share code, notes, and snippets.

@kamal
Created July 13, 2011 05:51
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 kamal/f8cdffb2aa6dccf2d72f to your computer and use it in GitHub Desktop.
Save kamal/f8cdffb2aa6dccf2d72f to your computer and use it in GitHub Desktop.
require "rubygems"
require "ruote"
require "ruote/storage/fs_storage"
require "ruote-kit"
require "freeagent_api"
engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::FsStorage.new('foo')))
RuoteKit.engine = engine
unless $RAKE_TASK # don't register participants in rake tasks
RuoteKit.engine.register do
# register your own participants using the participant method
#
# Example: participant 'alice', Ruote::StorageParticipant see
# http://ruote.rubyforge.org/participants.html for more info
# register the catchall storage participant named '.+'
catchall
end
end
RuoteKit.engine.register_participant :foo do |workitem|
puts "hello from foo"
end
p "after register foo"
RuoteKit.engine.register_participant :freeagent do |workitem|
case workitem.params['task']
when 'create contact'
contact = Freeagent::Contact.new(workitem.fields['coworker'])
contact.save
end
end
p "after register freeagent"
pdef = Ruote.process_definition :registration do
sequence do
foo :task => 'create contact'
freeagent :task => 'create contact'
end
end
p "after pdef"
wfid = RuoteKit.engine.launch(pdef, :coworker => {:first_name => 'foo'})
p "after launch"
RuoteKit.engine.wait_for(wfid)
p "after wait"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment