Skip to content

Instantly share code, notes, and snippets.

@ypz
Created September 18, 2013 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ypz/6614031 to your computer and use it in GitHub Desktop.
Save ypz/6614031 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'ruote'
require 'ruote/storage/fs_storage'
require 'pp'
abort("Usage: ack.rb <wfid>") if ARGV[0].nil?
wfid = ARGV[0]
ruote = Ruote::Dashboard.new(Ruote::FsStorage.new("/tmp/ruote_storage"))
sp = ruote.register_participant '.+', Ruote::StorageParticipant
wis = sp.by_wfid(wfid)
puts "found: #{wis.size}"
wis.each do | wi |
pp wi
wi.set_field('acknowledged', true)
sp.update(wi)
sp.proceed(wi)
end
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'ruote'
require 'ruote/storage/fs_storage'
@ruote = Ruote::Dashboard.new(Ruote::Worker.new(Ruote::FsStorage.new("/tmp/ruote_storage")))
class Alpha < ::Ruote::Participant
def on_workitem
puts "Alpha"
reply
end
end
class Bravo < ::Ruote::Participant
def on_workitem
puts "Bravo"
reply
end
end
class WaitForAck < ::Ruote::Participant
def on_workitem
if workitem.fields["acknowledged"] == true
puts "acknowledged"
else
puts "no ack from admin"
end
sleep 5
reply
end
end
@ruote.register 'alpha', Alpha
@ruote.register 'bravo', Bravo
@ruote.register 'wait_for_admin_ack', WaitForAck
@ruote.register_participant '.+', Ruote::StorageParticipant
pdef = Ruote.define 'test_pdef' do
cursor do
alpha
repeat do
wait_for_admin_ack
_break :if => '${f:acknowledged} == true'
end
bravo
end
end
wfid = @ruote.launch(pdef)
puts "launched wfid: #{wfid}"
@ruote.wait_for(wfid, :timeout=>10000)
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment