Class: DurableFlow::StepProxy
- Inherits:
-
Object
- Object
- DurableFlow::StepProxy
- Defined in:
- lib/durable_flow/step_proxy.rb
Instance Method Summary collapse
- #child_workflow(name, workflow_class = nil, *args, timeout: nil, on_failure: :raise, **kwargs, &block) ⇒ Object
- #child_workflows(name, collection = nil, key: nil, timeout: nil, concurrency: nil, on_failure: :raise, &block) ⇒ Object
- #each_child_workflow(name, collection, key:, timeout: nil, on_failure: :raise, &block) ⇒ Object
-
#initialize(workflow) ⇒ StepProxy
constructor
A new instance of StepProxy.
- #invoke(name, workflow_class = nil, *args, timeout: nil, on_failure: :raise, **kwargs, &block) ⇒ Object
- #invoke_each(name, collection, timeout: nil, concurrency: nil, on_failure: :raise, &block) ⇒ Object
- #run(name, start: nil, isolated: false, &block) ⇒ Object
- #sleep(name, duration = nil, **options) ⇒ Object
- #sleep_until(name, time) ⇒ Object
- #wait_for_event(name, event: nil, timeout: nil, match: {}, allow_past_events: false) ⇒ Object
- #wait_for_workflow(name, workflow_or_run_id, timeout: nil) ⇒ Object
- #workflow(workflow_class, *args, key:, **kwargs) ⇒ Object
Constructor Details
#initialize(workflow) ⇒ StepProxy
Returns a new instance of StepProxy.
5 6 7 |
# File 'lib/durable_flow/step_proxy.rb', line 5 def initialize(workflow) @workflow = workflow end |
Instance Method Details
#child_workflow(name, workflow_class = nil, *args, timeout: nil, on_failure: :raise, **kwargs, &block) ⇒ Object
42 43 44 |
# File 'lib/durable_flow/step_proxy.rb', line 42 def child_workflow(name, workflow_class = nil, *args, timeout: nil, on_failure: :raise, **kwargs, &block) @workflow.child_workflow(name, workflow_class, *args, timeout: timeout, on_failure: on_failure, **kwargs, &block) end |
#child_workflows(name, collection = nil, key: nil, timeout: nil, concurrency: nil, on_failure: :raise, &block) ⇒ Object
50 51 52 |
# File 'lib/durable_flow/step_proxy.rb', line 50 def child_workflows(name, collection = nil, key: nil, timeout: nil, concurrency: nil, on_failure: :raise, &block) @workflow.child_workflows(name, collection, key: key, timeout: timeout, concurrency: concurrency, on_failure: on_failure, &block) end |
#each_child_workflow(name, collection, key:, timeout: nil, on_failure: :raise, &block) ⇒ Object
58 59 60 |
# File 'lib/durable_flow/step_proxy.rb', line 58 def each_child_workflow(name, collection, key:, timeout: nil, on_failure: :raise, &block) @workflow.each_child_workflow(name, collection, key: key, timeout: timeout, on_failure: on_failure, &block) end |
#invoke(name, workflow_class = nil, *args, timeout: nil, on_failure: :raise, **kwargs, &block) ⇒ Object
46 47 48 |
# File 'lib/durable_flow/step_proxy.rb', line 46 def invoke(name, workflow_class = nil, *args, timeout: nil, on_failure: :raise, **kwargs, &block) @workflow.invoke_workflow(name, workflow_class, *args, timeout: timeout, on_failure: on_failure, **kwargs, &block) end |
#invoke_each(name, collection, timeout: nil, concurrency: nil, on_failure: :raise, &block) ⇒ Object
54 55 56 |
# File 'lib/durable_flow/step_proxy.rb', line 54 def invoke_each(name, collection, timeout: nil, concurrency: nil, on_failure: :raise, &block) @workflow.invoke_workflows(name, collection, timeout: timeout, concurrency: concurrency, on_failure: on_failure, &block) end |
#run(name, start: nil, isolated: false, &block) ⇒ Object
9 10 11 |
# File 'lib/durable_flow/step_proxy.rb', line 9 def run(name, start: nil, isolated: false, &block) @workflow.step(name, start: start, isolated: isolated, &block) end |
#sleep(name, duration = nil, **options) ⇒ Object
13 14 15 |
# File 'lib/durable_flow/step_proxy.rb', line 13 def sleep(name, duration = nil, **) @workflow.sleep_step(name, duration, until_time: [:until] || [:until_time]) end |
#sleep_until(name, time) ⇒ Object
17 18 19 |
# File 'lib/durable_flow/step_proxy.rb', line 17 def sleep_until(name, time) sleep(name, until: time) end |
#wait_for_event(name, event: nil, timeout: nil, match: {}, allow_past_events: false) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/durable_flow/step_proxy.rb', line 21 def wait_for_event(name, event: nil, timeout: nil, match: {}, allow_past_events: false) @workflow.wait_for_event_step( name, event_name: event || name, timeout: timeout, match: match, allow_past_events: allow_past_events, ) end |
#wait_for_workflow(name, workflow_or_run_id, timeout: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/durable_flow/step_proxy.rb', line 31 def wait_for_workflow(name, workflow_or_run_id, timeout: nil) run_id = workflow_or_run_id.respond_to?(:job_id) ? workflow_or_run_id.job_id : workflow_or_run_id.to_s wait_for_event( name, event: DurableFlow::WORKFLOW_COMPLETED_EVENT, timeout: timeout, match: { run_id: run_id }, allow_past_events: true, ) end |
#workflow(workflow_class, *args, key:, **kwargs) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/durable_flow/step_proxy.rb', line 62 def workflow(workflow_class, *args, key:, **kwargs) ChildWorkflowBuilder::Request.new( workflow_key: key.to_s, workflow_class: workflow_class, workflow_args: args, workflow_kwargs: kwargs ) end |