Module: Trailblazer::Activity::TaskWrap::Runner

Defined in:
lib/trailblazer/activity/task_wrap/runner.rb

Overview

The runner is passed into Activity#call( runner: Runner ) and is called for every task in the circuit. It runs the TaskWrap per task.

(wrap_ctx, original_args), **wrap_circuit_options

Class Method Summary collapse

Class Method Details

.call(task, args, **circuit_options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runner signature: call( task, direction, options, static_wraps )



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/trailblazer/activity/task_wrap/runner.rb', line 12

def self.call(task, args, **circuit_options)
  wrap_ctx = {task: task}

  # this pipeline is "wrapped around" the actual `task`.
  task_wrap_pipeline = merge_static_with_runtime(task, **circuit_options) || raise

  # We save all original args passed into this Runner.call, because we want to return them later after this wrap
  # is finished.
  original_args = [args, circuit_options]

  # call the wrap {Activity} around the task.
  wrap_ctx, _ = task_wrap_pipeline.(wrap_ctx, original_args) # we omit circuit_options here on purpose, so the wrapping activity uses the default, plain Runner.

  # don't return the wrap's end signal, but the one from call_task.
  # return all original_args for the next "real" task in the circuit (this includes circuit_options).

  return wrap_ctx[:return_signal], wrap_ctx[:return_args]
end