Skip to content

Instantly share code, notes, and snippets.

/replay_at_error.rb

Created Mar 15, 2013
Embed
What would you like to do?
# Gemfile
#
# ---8<---
# source :rubygems
#
# gem 'yajl-ruby', :require => 'yajl'
# #gem 'ruote'
# gem 'ruote', :git => 'git://github.com/jmettraux/ruote.git'
# --->8---
require 'pp'
require 'ruote'
ruote =
Ruote::Dashboard.new(
Ruote::Worker.new(
Ruote::HashStorage.new))
#ruote.noisy = (ENV['NOISY'] == 'true')
ruote.noisy = true
#
# define participant classes (if needed)
#
$error_mode = true
class AlphaParticipant < Ruote::Participant
def on_workitem
puts '- ' * 40
p :alpha
puts '- ' * 40
raise 'arghhhhhhhhhhh!' if $error_mode
reply
end
end
class BravoParticipant < Ruote::Participant
def on_workitem
puts '- ' * 40
p :bravo
puts '- ' * 40
reply
end
end
#
# register participants
#
ruote.register do
participant 'alpha', AlphaParticipant
participant 'bravo', BravoParticipant
end
#
# define process
#
pdef =
Ruote.define do
alpha
bravo
end
#
# run process
#
wfid = ruote.launch(pdef)
ruote.wait_for('error_intercepted')
err = ruote.ps(wfid).errors.first
puts '-' * 80
p '--replay_at_error--'
puts '-' * 80
$error_mode = false # fix issue
ruote.replay_at_error(err)
ruote.wait_for(wfid)
puts '-' * 80
p :over
puts '-' * 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.