server/handlerwrappers/default.rb in cpee-2.0.24 vs server/handlerwrappers/default.rb in cpee-2.0.25

- old
+ new

@@ -48,10 +48,12 @@ @handler_passthrough = nil @handler_returnValue = nil @handler_returnOptions = nil @handler_activity_uuid = Digest::MD5.hexdigest(Kernel::rand().to_s) @label = '' + @guard_files = [] + @guard_items = [] end # }}} def prepare(readonly, endpoints, parameters, replay=false) #{{{ if replay && @controller.attributes[:replayer] @handler_endpoint = @controller.attributes[:replayer] @@ -107,12 +109,12 @@ tendpoint = @handler_endpoint.sub(/^http(s)?-(get|put|post|delete):/,'http\\1:') type = $2 || parameters[:method] || 'post' client = Riddl::Client.new(tendpoint) - @controller.callback(self,callback,:'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position) @handler_passthrough = callback + @controller.callback(self,callback,:'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position) status, result, headers = client.request type => params if status < 200 || status >= 300 headers['CPEE_SALVAGE'] = true c = result[0]&.value @@ -259,12 +261,12 @@ end end def callback(result=nil,options={}) @controller.notify("activity/receiving", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result), :sensors => @sensors, :aggregators => @aggregators, :costs => @costs) - result = simplify_result(result) - @handler_returnValue = result + @guard_files += result + @handler_returnValue = simplify_result(result) @handler_returnOptions = options if options['CPEE_UPDATE'] if options['CPEE_UPDATE_STATUS'] @controller.notify("activity/status", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS']) end @@ -277,9 +279,19 @@ else @handler_continue.continue end end end + + def mem_guard() #{{{ + @guard_files.each do |p| + if p&.respond_to?(:close) + p.close + elsif p&.value&.respond_to?(:close) + p.value.close + end + end + end #}}} def test_condition(mr,code) res = mr.instance_eval(code) @controller.notify("condition/eval", :instance_uuid => @controller.uuid, :code => code, :condition => (res ? "true" : "false")) res