-
-
Save kamal/f8cdffb2aa6dccf2d72f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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