|
8 | 8 | require 'temporalio/client/interceptor'
|
9 | 9 | require 'temporalio/client/schedule'
|
10 | 10 | require 'temporalio/client/schedule_handle'
|
| 11 | +require 'temporalio/client/with_start_workflow_operation' |
11 | 12 | require 'temporalio/client/workflow_execution'
|
12 | 13 | require 'temporalio/client/workflow_execution_count'
|
13 | 14 | require 'temporalio/client/workflow_handle'
|
14 | 15 | require 'temporalio/client/workflow_query_reject_condition'
|
| 16 | +require 'temporalio/client/workflow_update_handle' |
| 17 | +require 'temporalio/client/workflow_update_wait_stage' |
15 | 18 | require 'temporalio/common_enums'
|
16 | 19 | require 'temporalio/converters'
|
17 | 20 | require 'temporalio/error'
|
@@ -155,7 +158,7 @@ def initialize(
|
155 | 158 | default_workflow_query_reject_condition:
|
156 | 159 | ).freeze
|
157 | 160 | # Initialize interceptors
|
158 |
| - @impl = interceptors.reverse_each.reduce(Internal::Client::Implementation.new(self)) do |acc, int| |
| 161 | + @impl = interceptors.reverse_each.reduce(Internal::Client::Implementation.new(self)) do |acc, int| # steep:ignore |
159 | 162 | int.intercept_client(acc)
|
160 | 163 | end
|
161 | 164 | end
|
@@ -334,6 +337,106 @@ def workflow_handle(
|
334 | 337 | WorkflowHandle.new(client: self, id: workflow_id, run_id:, result_run_id: run_id, first_execution_run_id:)
|
335 | 338 | end
|
336 | 339 |
|
| 340 | + # Start an update, possibly starting the workflow at the same time if it doesn't exist (depending upon ID conflict |
| 341 | + # policy). Note that in some cases this may fail but the workflow will still be started, and the handle can then be |
| 342 | + # retrieved on the start workflow operation. |
| 343 | + # |
| 344 | + # @param update [Workflow::Definition::Update, Symbol, String] Update definition or name. |
| 345 | + # @param args [Array<Object>] Update arguments. |
| 346 | + # @param start_workflow_operation [WithStartWorkflowOperation] Required with-start workflow operation. This must |
| 347 | + # have an `id_conflict_policy` set. |
| 348 | + # @param wait_for_stage [WorkflowUpdateWaitStage] Required stage to wait until returning. ADMITTED is not |
| 349 | + # currently supported. See https://docs.temporal.io/workflows#update for more details. |
| 350 | + # @param id [String] ID of the update. |
| 351 | + # @param rpc_options [RPCOptions, nil] Advanced RPC options. |
| 352 | + # |
| 353 | + # @return [WorkflowUpdateHandle] The update handle. |
| 354 | + # @raise [Error::WorkflowAlreadyStartedError] Workflow already exists and conflict/reuse policy does not allow. |
| 355 | + # @raise [Error::WorkflowUpdateRPCTimeoutOrCanceledError] This update call timed out or was canceled. This doesn't |
| 356 | + # mean the update itself was timed out or canceled, and this doesn't mean the workflow did not start. |
| 357 | + # @raise [Error::RPCError] RPC error from call. |
| 358 | + def start_update_with_start_workflow( |
| 359 | + update, |
| 360 | + *args, |
| 361 | + start_workflow_operation:, |
| 362 | + wait_for_stage:, |
| 363 | + id: SecureRandom.uuid, |
| 364 | + rpc_options: nil |
| 365 | + ) |
| 366 | + @impl.start_update_with_start_workflow( |
| 367 | + Interceptor::StartUpdateWithStartWorkflowInput.new( |
| 368 | + update_id: id, |
| 369 | + update:, |
| 370 | + args:, |
| 371 | + wait_for_stage:, |
| 372 | + start_workflow_operation:, |
| 373 | + headers: {}, |
| 374 | + rpc_options: |
| 375 | + ) |
| 376 | + ) |
| 377 | + end |
| 378 | + |
| 379 | + # Start an update, possibly starting the workflow at the same time if it doesn't exist (depending upon ID conflict |
| 380 | + # policy), and wait for update result. This is a shortcut for {start_update_with_start_workflow} + |
| 381 | + # {WorkflowUpdateHandle.result}. |
| 382 | + # |
| 383 | + # @param update [Workflow::Definition::Update, Symbol, String] Update definition or name. |
| 384 | + # @param args [Array<Object>] Update arguments. |
| 385 | + # @param start_workflow_operation [WithStartWorkflowOperation] Required with-start workflow operation. This must |
| 386 | + # have an `id_conflict_policy` set. |
| 387 | + # @param id [String] ID of the update. |
| 388 | + # @param rpc_options [RPCOptions, nil] Advanced RPC options. |
| 389 | + # |
| 390 | + # @return [Object] Successful update result. |
| 391 | + # @raise [Error::WorkflowUpdateFailedError] If the update failed. |
| 392 | + # @raise [Error::WorkflowAlreadyStartedError] Workflow already exists and conflict/reuse policy does not allow. |
| 393 | + # @raise [Error::WorkflowUpdateRPCTimeoutOrCanceledError] This update call timed out or was canceled. This doesn't |
| 394 | + # mean the update itself was timed out or canceled, and this doesn't mean the workflow did not start. |
| 395 | + # @raise [Error::RPCError] RPC error from call. |
| 396 | + def execute_update_with_start_workflow( |
| 397 | + update, |
| 398 | + *args, |
| 399 | + start_workflow_operation:, |
| 400 | + id: SecureRandom.uuid, |
| 401 | + rpc_options: nil |
| 402 | + ) |
| 403 | + start_update_with_start_workflow( |
| 404 | + update, |
| 405 | + *args, |
| 406 | + start_workflow_operation:, |
| 407 | + wait_for_stage: WorkflowUpdateWaitStage::COMPLETED, |
| 408 | + id:, |
| 409 | + rpc_options: |
| 410 | + ).result |
| 411 | + end |
| 412 | + |
| 413 | + # Send a signal, possibly starting the workflow at the same time if it doesn't exist. |
| 414 | + # |
| 415 | + # @param signal [Workflow::Definition::Signal, Symbol, String] Signal definition or name. |
| 416 | + # @param args [Array<Object>] Signal arguments. |
| 417 | + # @param start_workflow_operation [WithStartWorkflowOperation] Required with-start workflow operation. This may not |
| 418 | + # support all `id_conflict_policy` options. |
| 419 | + # @param rpc_options [RPCOptions, nil] Advanced RPC options. |
| 420 | + # |
| 421 | + # @return [WorkflowHandle] A workflow handle to the workflow. |
| 422 | + # @raise [Error::WorkflowAlreadyStartedError] Workflow already exists and conflict/reuse policy does not allow. |
| 423 | + # @raise [Error::RPCError] RPC error from call. |
| 424 | + def signal_with_start_workflow( |
| 425 | + signal, |
| 426 | + *args, |
| 427 | + start_workflow_operation:, |
| 428 | + rpc_options: nil |
| 429 | + ) |
| 430 | + @impl.signal_with_start_workflow( |
| 431 | + Interceptor::SignalWithStartWorkflowInput.new( |
| 432 | + signal:, |
| 433 | + args:, |
| 434 | + start_workflow_operation:, |
| 435 | + rpc_options: |
| 436 | + ) |
| 437 | + ) |
| 438 | + end |
| 439 | + |
337 | 440 | # List workflows.
|
338 | 441 | #
|
339 | 442 | # @param query [String, nil] A Temporal visibility list filter.
|
|
0 commit comments