lib/ruote/worker.rb in ruote-2.1.4 vs lib/ruote/worker.rb in ruote-2.1.5
- old
+ new
@@ -25,11 +25,11 @@
require 'ruote/fei'
module Ruote
- VERSION = '2.1.4'
+ VERSION = '2.1.5'
class Worker
EXP_ACTIONS = %w[ reply cancel fail receive ]
# 'apply' is comprised in 'launch'
@@ -135,10 +135,11 @@
@storage.put(
'type' => 'errors',
'_id' => "err_#{Ruote.to_storage_id(fei)}",
'message' => ex.inspect,
'trace' => ex.backtrace.join("\n"),
+ 'fei' => fei,
'msg' => msg
) if fei
end
protected
@@ -152,11 +153,11 @@
#
# at most once per second, deal with 'ats' and 'crons'
@last_time = now
- @storage.get_schedules(delta, now).each do|sche|
+ @storage.get_schedules(delta, now).each do |sche|
trigger(sche)
end
end
# msgs
@@ -281,12 +282,13 @@
# msg['wfid'] only : it's a launch
# msg['fei'] : it's a sub launch (a supplant ?)
exp_hash = {
'fei' => msg['fei'] || {
- 'engine_id' => @context['engine_id'] || 'engine',
+ 'engine_id' => @context.engine_id,
'wfid' => msg['wfid'],
+ 'sub_wfid' => msg['sub_wfid'],
'expid' => '0' },
'parent_id' => msg['parent_id'],
'original_tree' => tree,
'variables' => variables,
'applied_workitem' => msg['workitem'],
@@ -301,21 +303,38 @@
def_name, tree = Ruote::Exp::DefineExpression.reorganize(tree)
variables[def_name] = [ '0', tree ] if def_name
exp_class = Ruote::Exp::SequenceExpression
end
+ if exp_class == Ruote::Exp::SubprocessExpression && tree[1]['engine']
+ #
+ # the subprocess has to be transformed into an EngineParticipant...
+
+ exp_class = Ruote::Exp::ParticipantExpression
+
+ atts = tree[1]
+
+ if ref = atts.find { |k, v| v.nil? }
+ ref = ref.first
+ atts.delete(ref)
+ end
+
+ atts['pdef'] = atts['ref'] || ref
+ atts['ref'] = atts.delete('engine')
+ end
+
raise_unknown_expression_error(exp_hash) unless exp_class
exp = exp_class.new(@context, exp_hash.merge!('original_tree' => tree))
exp.initial_persist
exp.do_apply
end
def raise_unknown_expression_error (exp_hash)
exp_hash['state'] = 'failed'
- exp_hash['has_error'] = true
+ #exp_hash['has_error'] = true
Ruote::Exp::RawExpression.new(@context, exp_hash).persist_or_raise
# undigested expression is stored
raise "unknown expression '#{exp_hash['original_tree'].first}'"
@@ -338,15 +357,17 @@
if sub or part
tree[1]['ref'] = key
tree[1]['original_ref'] = tree[0] if key != tree[0]
- tree[0] = sub ? 'subprocess' : 'participant'
+ if sub
- [ sub ?
- Ruote::Exp::SubprocessExpression :
- Ruote::Exp::ParticipantExpression,
- tree ]
+ [ Ruote::Exp::SubprocessExpression, [ 'subprocess', *tree[1..2] ] ]
+
+ else
+
+ [ Ruote::Exp::ParticipantExpression, [ 'participant', *tree[1..2] ] ]
+ end
else
[ nil, tree ]
end
end