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, arg_hints: nil, result_hint: 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.



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
82
83
84
85
86
87
88
89
# File 'lib/temporalio/client/with_start_workflow_operation.rb', line 43

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,
  arg_hints: nil,
  result_hint: nil,
  headers: {}
)
  workflow, defn_arg_hints, defn_result_hint =
    Workflow::Definition._workflow_type_and_hints_from_workflow_parameter(workflow)
  @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:,
    arg_hints: arg_hints || defn_arg_hints,
    result_hint: result_hint || defn_result_hint,
    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.



36
37
38
# File 'lib/temporalio/client/with_start_workflow_operation.rb', line 36

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.



98
99
100
101
102
103
104
105
# File 'lib/temporalio/client/with_start_workflow_operation.rb', line 98

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