module Proxy::Dynflow::Helpers
Public Instance Methods
cancel_task(task_id)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 30 def cancel_task(task_id) execution_plan = world.persistence.load_execution_plan(task_id) cancel_events = execution_plan.cancel { :task_id => task_id, :canceled_steps_count => cancel_events.size } end
dispatch_external_event(task_id, params)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 55 def dispatch_external_event(task_id, params) world.event(task_id, params['step_id'].to_i, ::Proxy::Dynflow::Runner::ExternalEvent.new(params)) end
expand_output(action)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 67 def expand_output(action) hash = action.to_hash hash[:output][:result] = action.output_result if action.is_a?(Proxy::Dynflow::Action::Runner) hash end
refresh_output(execution_plan, action)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 61 def refresh_output(execution_plan, action) if action.is_a?(Proxy::Dynflow::Action::WithExternalPolling) && %i[running suspended].include?(action.run_step&.state) world.event(execution_plan.id, action.run_step_id, Proxy::Dynflow::Action::WithExternalPolling::Poll) end end
task_status(task_id)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 36 def task_status(task_id) ep = world.persistence.load_execution_plan(task_id) actions = ep.actions.map do |action| refresh_output(ep, action) expand_output(action) end ep.to_hash.merge(:actions => actions) rescue KeyError => _e status 404 {} end
tasks_count(state)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 48 def tasks_count(state) state ||= 'all' filter = state != 'all' ? { :filters => { :state => [state] } } : {} tasks = world.persistence.find_execution_plans(filter) { :count => tasks.count, :state => state } end
trigger_task(*args)
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 25 def trigger_task(*args) triggered = world.trigger(*args) { :task_id => triggered.id } end
world()
click to toggle source
# File lib/smart_proxy_dynflow/helpers.rb, line 4 def world Proxy::Dynflow::Core.world end