Class: Temporalio::Client::WithStartWorkflowOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/client/with_start_workflow_operation.rb

Overview

Defined Under Namespace

Classes: Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow, *args, id:, task_queue:, static_summary: nil, static_details: nil, execution_timeout: nil, run_timeout: nil, task_timeout: nil, id_reuse_policy: WorkflowIDReusePolicy::ALLOW_DUPLICATE, id_conflict_policy: WorkflowIDConflictPolicy::UNSPECIFIED, retry_policy: nil, cron_schedule: nil, memo: nil, search_attributes: nil, start_delay: nil, headers: {}) ⇒ WithStartWorkflowOperation

Create a with-start workflow operation. These are mostly the same options as Temporalio::Client#start_workflow, see that documentation for more details.

Note, for Temporalio::Client#start_update_with_start_workflow and Temporalio::Client#execute_update_with_start_workflow, ‘id_conflict_policy` is required.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/temporalio/client/with_start_workflow_operation.rb', line 41

def initialize(
  workflow,
  *args,
  id:,
  task_queue:,
  static_summary: nil,
  static_details: nil,
  execution_timeout: nil,
  run_timeout: nil,
  task_timeout: nil,
  id_reuse_policy: WorkflowIDReusePolicy::ALLOW_DUPLICATE,
  id_conflict_policy: WorkflowIDConflictPolicy::UNSPECIFIED,
  retry_policy: nil,
  cron_schedule: nil,
  memo: nil,
  search_attributes: nil,
  start_delay: nil,
  headers: {}
)
  @options = Options.new(
    workflow:,
    args:,
    id:,
    task_queue:,
    static_summary:,
    static_details:,
    execution_timeout:,
    run_timeout:,
    task_timeout:,
    id_reuse_policy:,
    id_conflict_policy:,
    retry_policy:,
    cron_schedule:,
    memo:,
    search_attributes:,
    start_delay:,
    headers:
  )
  @workflow_handle_mutex = Mutex.new
  @workflow_handle_cond_var = ConditionVariable.new
end

Instance Attribute Details

#optionsOptions

Returns Options the operation was created with.

Returns:

  • (Options)

    Options the operation was created with.



34
35
36
# File 'lib/temporalio/client/with_start_workflow_operation.rb', line 34

def options
  @options
end

Instance Method Details

#workflow_handle(wait: true) ⇒ WorkflowHandle?

Get the workflow handle, possibly waiting until set, or raise an error if the workflow start was unsuccessful.

Parameters:

  • wait (Boolean) (defaults to: true)

    True to wait until it is set, false to return immediately.

Returns:

  • (WorkflowHandle, nil)

    The workflow handle when available or ‘nil` if `wait` is false and it is not set yet.

Raises:

  • (Error)

    Any error that occurred during the call before the workflow start returned.



90
91
92
93
94
95
96
97
# File 'lib/temporalio/client/with_start_workflow_operation.rb', line 90

def workflow_handle(wait: true)
  @workflow_handle_mutex.synchronize do
    @workflow_handle_cond_var.wait(@workflow_handle_mutex) unless @workflow_handle || !wait
    raise @workflow_handle if @workflow_handle.is_a?(Exception)

    @workflow_handle
  end
end