Skip to content

Instantly share code, notes, and snippets.

@ypz
Created November 14, 2013 01:20
Show Gist options
  • Save ypz/7459621 to your computer and use it in GitHub Desktop.
Save ypz/7459621 to your computer and use it in GitHub Desktop.
test pdef for repeat loop
#!/usr/bin/env ruby
require 'ruote'
class Alpha < ::Ruote::Participant
def on_workitem
n = workitem.fields["iteration"].nil? ? 1 : workitem.fields["iteration"] + 1
workitem.set_field("iteration", n)
workitem.set_field("completed", true) if n >= 10
puts `date`
puts "#{workitem.participant_name}: iteration #{n}"
puts ""
reply
end
end
@ruote = Ruote::Dashboard.new(Ruote::Worker.new(Ruote::HashStorage.new()))
@ruote.register 'alpha', Alpha
pdef = Ruote.define do
repeat do
alpha
# wait '5s'
_break :if => '${f:completed}'
end
echo "all done"
end
fields = {:completed => false}
wfid = @ruote.launch(pdef, fields)
@ruote.wait_for(wfid, :timeout => 60*1000)
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment