Created
November 14, 2013 01:20
-
-
Save ypz/7459621 to your computer and use it in GitHub Desktop.
test pdef for repeat loop
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
#!/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