temporalio 0.4.0-x86_64-linux → 0.6.0-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/lib/temporalio/activity/cancellation_details.rb +58 -0
- data/lib/temporalio/activity/context.rb +10 -1
- data/lib/temporalio/activity/definition.rb +41 -3
- data/lib/temporalio/activity/info.rb +25 -4
- data/lib/temporalio/activity.rb +2 -0
- data/lib/temporalio/api/activity/v1/message.rb +1 -1
- data/lib/temporalio/api/batch/v1/message.rb +7 -2
- data/lib/temporalio/api/cloud/account/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +22 -2
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +2 -2
- data/lib/temporalio/api/cloud/connectivityrule/v1/message.rb +29 -0
- data/lib/temporalio/api/cloud/identity/v1/message.rb +7 -2
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +7 -2
- data/lib/temporalio/api/cloud/nexus/v1/message.rb +3 -2
- data/lib/temporalio/api/cloud/operation/v1/message.rb +2 -2
- data/lib/temporalio/api/cloud/region/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/resource/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/sink/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/usage/v1/message.rb +1 -1
- data/lib/temporalio/api/command/v1/message.rb +2 -2
- data/lib/temporalio/api/common/v1/grpc_status.rb +1 -1
- data/lib/temporalio/api/common/v1/message.rb +4 -2
- data/lib/temporalio/api/deployment/v1/message.rb +3 -2
- data/lib/temporalio/api/enums/v1/batch_operation.rb +2 -2
- data/lib/temporalio/api/enums/v1/command_type.rb +1 -1
- data/lib/temporalio/api/enums/v1/common.rb +5 -2
- data/lib/temporalio/api/enums/v1/deployment.rb +3 -2
- data/lib/temporalio/api/enums/v1/event_type.rb +2 -2
- data/lib/temporalio/api/enums/v1/failed_cause.rb +2 -2
- data/lib/temporalio/api/enums/v1/namespace.rb +1 -1
- data/lib/temporalio/api/enums/v1/nexus.rb +1 -1
- data/lib/temporalio/api/enums/v1/query.rb +1 -1
- data/lib/temporalio/api/enums/v1/reset.rb +1 -1
- data/lib/temporalio/api/enums/v1/schedule.rb +1 -1
- data/lib/temporalio/api/enums/v1/task_queue.rb +3 -2
- data/lib/temporalio/api/enums/v1/update.rb +1 -1
- data/lib/temporalio/api/enums/v1/workflow.rb +2 -2
- data/lib/temporalio/api/errordetails/v1/message.rb +1 -1
- data/lib/temporalio/api/export/v1/message.rb +1 -1
- data/lib/temporalio/api/failure/v1/message.rb +3 -2
- data/lib/temporalio/api/filter/v1/message.rb +1 -1
- data/lib/temporalio/api/history/v1/message.rb +4 -2
- data/lib/temporalio/api/namespace/v1/message.rb +1 -1
- data/lib/temporalio/api/nexus/v1/message.rb +2 -2
- data/lib/temporalio/api/operatorservice/v1/request_response.rb +1 -1
- data/lib/temporalio/api/operatorservice/v1/service.rb +1 -1
- data/lib/temporalio/api/payload_visitor.rb +106 -1
- data/lib/temporalio/api/protocol/v1/message.rb +1 -1
- data/lib/temporalio/api/query/v1/message.rb +1 -1
- data/lib/temporalio/api/replication/v1/message.rb +1 -1
- data/lib/temporalio/api/rules/v1/message.rb +27 -0
- data/lib/temporalio/api/schedule/v1/message.rb +2 -2
- data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +1 -1
- data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +1 -1
- data/lib/temporalio/api/sdk/v1/user_metadata.rb +1 -1
- data/lib/temporalio/api/sdk/v1/worker_config.rb +23 -0
- data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +1 -1
- data/lib/temporalio/api/taskqueue/v1/message.rb +6 -2
- data/lib/temporalio/api/testservice/v1/request_response.rb +1 -1
- data/lib/temporalio/api/testservice/v1/service.rb +1 -1
- data/lib/temporalio/api/update/v1/message.rb +1 -1
- data/lib/temporalio/api/version/v1/message.rb +1 -1
- data/lib/temporalio/api/worker/v1/message.rb +31 -0
- data/lib/temporalio/api/workflow/v1/message.rb +14 -2
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +28 -2
- data/lib/temporalio/api/workflowservice/v1/service.rb +2 -2
- data/lib/temporalio/cancellation.rb +16 -12
- data/lib/temporalio/client/async_activity_handle.rb +12 -4
- data/lib/temporalio/client/connection/cloud_service.rb +135 -0
- data/lib/temporalio/client/connection/workflow_service.rb +150 -0
- data/lib/temporalio/client/connection.rb +2 -1
- data/lib/temporalio/client/interceptor.rb +25 -7
- data/lib/temporalio/client/schedule.rb +10 -2
- data/lib/temporalio/client/with_start_workflow_operation.rb +9 -1
- data/lib/temporalio/client/workflow_handle.rb +50 -10
- data/lib/temporalio/client/workflow_update_handle.rb +9 -3
- data/lib/temporalio/client.rb +110 -6
- data/lib/temporalio/common_enums.rb +14 -0
- data/lib/temporalio/contrib/open_telemetry.rb +7 -7
- data/lib/temporalio/converters/data_converter.rb +18 -8
- data/lib/temporalio/converters/failure_converter.rb +6 -3
- data/lib/temporalio/converters/payload_converter/binary_null.rb +2 -2
- data/lib/temporalio/converters/payload_converter/binary_plain.rb +2 -2
- data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +2 -2
- data/lib/temporalio/converters/payload_converter/composite.rb +6 -4
- data/lib/temporalio/converters/payload_converter/encoding.rb +4 -2
- data/lib/temporalio/converters/payload_converter/json_plain.rb +24 -7
- data/lib/temporalio/converters/payload_converter/json_protobuf.rb +2 -2
- data/lib/temporalio/converters/payload_converter.rb +16 -6
- data/lib/temporalio/error/failure.rb +19 -1
- data/lib/temporalio/error.rb +1 -1
- data/lib/temporalio/internal/bridge/3.2/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/3.3/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/3.4/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +1 -1
- data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +3 -2
- data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +1 -1
- data/lib/temporalio/internal/bridge/api/common/common.rb +1 -1
- data/lib/temporalio/internal/bridge/api/core_interface.rb +1 -1
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +1 -1
- data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +3 -2
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +2 -2
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +3 -2
- data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +1 -1
- data/lib/temporalio/internal/bridge/worker.rb +28 -4
- data/lib/temporalio/internal/bridge.rb +1 -1
- data/lib/temporalio/internal/client/implementation.rb +60 -52
- data/lib/temporalio/internal/proto_utils.rb +4 -4
- data/lib/temporalio/internal/worker/activity_worker.rb +93 -20
- data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +8 -6
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +66 -24
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +5 -2
- data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +2 -2
- data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +2 -0
- data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +64 -18
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +28 -14
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +5 -2
- data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +10 -4
- data/lib/temporalio/internal/worker/workflow_instance.rb +58 -23
- data/lib/temporalio/internal/worker/workflow_worker.rb +16 -6
- data/lib/temporalio/priority.rb +100 -0
- data/lib/temporalio/scoped_logger.rb +1 -1
- data/lib/temporalio/testing/activity_environment.rb +17 -2
- data/lib/temporalio/testing/workflow_environment.rb +3 -3
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/versioning_override.rb +56 -0
- data/lib/temporalio/worker/deployment_options.rb +45 -0
- data/lib/temporalio/worker/illegal_workflow_call_validator.rb +73 -0
- data/lib/temporalio/worker/interceptor.rb +13 -1
- data/lib/temporalio/worker/poller_behavior.rb +61 -0
- data/lib/temporalio/worker/thread_pool.rb +1 -1
- data/lib/temporalio/worker/workflow_executor/thread_pool.rb +2 -1
- data/lib/temporalio/worker/workflow_replayer.rb +12 -13
- data/lib/temporalio/worker.rb +73 -28
- data/lib/temporalio/worker_deployment_version.rb +67 -0
- data/lib/temporalio/workflow/child_workflow_handle.rb +10 -2
- data/lib/temporalio/workflow/definition.rb +187 -39
- data/lib/temporalio/workflow/external_workflow_handle.rb +3 -1
- data/lib/temporalio/workflow/info.rb +4 -1
- data/lib/temporalio/workflow.rb +134 -11
- data/lib/temporalio.rb +1 -0
- data/temporalio.gemspec +1 -0
- metadata +13 -2
| @@ -48,13 +48,21 @@ module Temporalio | |
| 48 48 | 
             
                  # @return [String, nil] First execution run ID.
         | 
| 49 49 | 
             
                  attr_reader :first_execution_run_id
         | 
| 50 50 |  | 
| 51 | 
            +
                  # Result hint for the result of this workflow. If this handle was created via {Client.start_workflow}, this is set
         | 
| 52 | 
            +
                  # from there (either via result hint on that call or workflow definition's result hint). Otherwise, the result
         | 
| 53 | 
            +
                  # hint is set by the creator of the handle.
         | 
| 54 | 
            +
                  #
         | 
| 55 | 
            +
                  # @return [Object, nil] Result hint.
         | 
| 56 | 
            +
                  attr_reader :result_hint
         | 
| 57 | 
            +
             | 
| 51 58 | 
             
                  # @!visibility private
         | 
| 52 | 
            -
                  def initialize(client:, id:, run_id:, result_run_id:, first_execution_run_id:)
         | 
| 59 | 
            +
                  def initialize(client:, id:, run_id:, result_run_id:, first_execution_run_id:, result_hint:)
         | 
| 53 60 | 
             
                    @client = client
         | 
| 54 61 | 
             
                    @id = id
         | 
| 55 62 | 
             
                    @run_id = run_id
         | 
| 56 63 | 
             
                    @result_run_id = result_run_id
         | 
| 57 64 | 
             
                    @first_execution_run_id = first_execution_run_id
         | 
| 65 | 
            +
                    @result_hint = result_hint
         | 
| 58 66 | 
             
                  end
         | 
| 59 67 |  | 
| 60 68 | 
             
                  # Wait for the result of the workflow.
         | 
| @@ -64,6 +72,8 @@ module Temporalio | |
| 64 72 | 
             
                  #
         | 
| 65 73 | 
             
                  # @param follow_runs [Boolean] If +true+, workflow runs will be continually fetched across retries and continue as
         | 
| 66 74 | 
             
                  #   new until the latest one is found. If +false+, the first result is used.
         | 
| 75 | 
            +
                  # @param result_hint [Object, nil] Override the result hint for the result. If unset/nil, uses one on the handle
         | 
| 76 | 
            +
                  #   itself.
         | 
| 67 77 | 
             
                  # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 68 78 | 
             
                  #
         | 
| 69 79 | 
             
                  # @return [Object] Result of the workflow after being converted by the data converter.
         | 
| @@ -71,7 +81,7 @@ module Temporalio | |
| 71 81 | 
             
                  # @raise [Error::WorkflowFailedError] Workflow failed with +cause+ as the cause.
         | 
| 72 82 | 
             
                  # @raise [Error::WorkflowContinuedAsNewError] Workflow continued as new and +follow_runs+ is +false+.
         | 
| 73 83 | 
             
                  # @raise [Error::RPCError] RPC error from call.
         | 
| 74 | 
            -
                  def result(follow_runs: true, rpc_options: nil)
         | 
| 84 | 
            +
                  def result(follow_runs: true, result_hint: nil, rpc_options: nil)
         | 
| 75 85 | 
             
                    # Wait on the close event, following as needed
         | 
| 76 86 | 
             
                    hist_run_id = result_run_id
         | 
| 77 87 | 
             
                    loop do
         | 
| @@ -91,7 +101,7 @@ module Temporalio | |
| 91 101 | 
             
                        hist_run_id = attrs.new_execution_run_id
         | 
| 92 102 | 
             
                        next if follow_runs && hist_run_id && !hist_run_id.empty?
         | 
| 93 103 |  | 
| 94 | 
            -
                        return @client.data_converter.from_payloads(attrs.result).first
         | 
| 104 | 
            +
                        return @client.data_converter.from_payloads(attrs.result, hints: Array(@result_hint || result_hint)).first
         | 
| 95 105 | 
             
                      when :EVENT_TYPE_WORKFLOW_EXECUTION_FAILED
         | 
| 96 106 | 
             
                        attrs = event.workflow_execution_failed_event_attributes
         | 
| 97 107 | 
             
                        hist_run_id = attrs.new_execution_run_id
         | 
| @@ -212,18 +222,22 @@ module Temporalio | |
| 212 222 | 
             
                  #
         | 
| 213 223 | 
             
                  # @param signal [Workflow::Definition::Signal, Symbol, String] Signal definition or name.
         | 
| 214 224 | 
             
                  # @param args [Array<Object>] Signal arguments.
         | 
| 225 | 
            +
                  # @param arg_hints [Array<Object>, nil] Signal argument hints. If unset/nil and a signal definition is passed,
         | 
| 226 | 
            +
                  #   uses the ones on the signal definition if present.
         | 
| 215 227 | 
             
                  # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 216 228 | 
             
                  #
         | 
| 217 229 | 
             
                  # @raise [Error::RPCError] RPC error from call.
         | 
| 218 230 | 
             
                  #
         | 
| 219 231 | 
             
                  # @note Handles created as a result of {Client.start_workflow} will signal the latest workflow with the same
         | 
| 220 232 | 
             
                  #   workflow ID even if it is unrelated to the started workflow.
         | 
| 221 | 
            -
                  def signal(signal, *args, rpc_options: nil)
         | 
| 233 | 
            +
                  def signal(signal, *args, arg_hints: nil, rpc_options: nil)
         | 
| 234 | 
            +
                    signal, defn_arg_hints = Workflow::Definition::Signal._name_and_hints_from_parameter(signal)
         | 
| 222 235 | 
             
                    @client._impl.signal_workflow(Interceptor::SignalWorkflowInput.new(
         | 
| 223 236 | 
             
                                                    workflow_id: id,
         | 
| 224 237 | 
             
                                                    run_id:,
         | 
| 225 | 
            -
                                                    signal | 
| 238 | 
            +
                                                    signal:,
         | 
| 226 239 | 
             
                                                    args:,
         | 
| 240 | 
            +
                                                    arg_hints: arg_hints || defn_arg_hints,
         | 
| 227 241 | 
             
                                                    headers: {},
         | 
| 228 242 | 
             
                                                    rpc_options:
         | 
| 229 243 | 
             
                                                  ))
         | 
| @@ -235,6 +249,10 @@ module Temporalio | |
| 235 249 | 
             
                  # @param query [Workflow::Definition::Query, Symbol, String] Query definition or name.
         | 
| 236 250 | 
             
                  # @param args [Array<Object>] Query arguments.
         | 
| 237 251 | 
             
                  # @param reject_condition [WorkflowQueryRejectCondition, nil] Condition for rejecting the query.
         | 
| 252 | 
            +
                  # @param arg_hints [Array<Object>, nil] Query argument hints. If unset/nil and a query definition is passed,
         | 
| 253 | 
            +
                  #   uses the ones on the query definition if present.
         | 
| 254 | 
            +
                  # @param result_hint [Object, nil] Query result hints. If unset/nil and a query definition is passed, uses the
         | 
| 255 | 
            +
                  #   one on the query definition if present.
         | 
| 238 256 | 
             
                  # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 239 257 | 
             
                  #
         | 
| 240 258 | 
             
                  # @return [Object, nil] Query result.
         | 
| @@ -249,14 +267,19 @@ module Temporalio | |
| 249 267 | 
             
                    query,
         | 
| 250 268 | 
             
                    *args,
         | 
| 251 269 | 
             
                    reject_condition: @client.options.default_workflow_query_reject_condition,
         | 
| 270 | 
            +
                    arg_hints: nil,
         | 
| 271 | 
            +
                    result_hint: nil,
         | 
| 252 272 | 
             
                    rpc_options: nil
         | 
| 253 273 | 
             
                  )
         | 
| 274 | 
            +
                    query, defn_arg_hints, defn_result_hint = Workflow::Definition::Query._name_and_hints_from_parameter(query)
         | 
| 254 275 | 
             
                    @client._impl.query_workflow(Interceptor::QueryWorkflowInput.new(
         | 
| 255 276 | 
             
                                                   workflow_id: id,
         | 
| 256 277 | 
             
                                                   run_id:,
         | 
| 257 | 
            -
                                                   query | 
| 278 | 
            +
                                                   query:,
         | 
| 258 279 | 
             
                                                   args:,
         | 
| 259 280 | 
             
                                                   reject_condition:,
         | 
| 281 | 
            +
                                                   arg_hints: arg_hints || defn_arg_hints,
         | 
| 282 | 
            +
                                                   result_hint: result_hint || defn_result_hint,
         | 
| 260 283 | 
             
                                                   headers: {},
         | 
| 261 284 | 
             
                                                   rpc_options:
         | 
| 262 285 | 
             
                                                 ))
         | 
| @@ -270,6 +293,10 @@ module Temporalio | |
| 270 293 | 
             
                  # @param wait_for_stage [WorkflowUpdateWaitStage] Required stage to wait until returning. ADMITTED is not
         | 
| 271 294 | 
             
                  #   currently supported. See https://docs.temporal.io/workflows#update for more details.
         | 
| 272 295 | 
             
                  # @param id [String] ID of the update.
         | 
| 296 | 
            +
                  # @param arg_hints [Array<Object>, nil] Update argument hints. If unset/nil and am update definition is passed,
         | 
| 297 | 
            +
                  #   uses the ones on the update definition if present.
         | 
| 298 | 
            +
                  # @param result_hint [Object, nil] Update result hints. If unset/nil and an update definition is passed, uses the
         | 
| 299 | 
            +
                  #   one on the update definition if present.
         | 
| 273 300 | 
             
                  # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 274 301 | 
             
                  #
         | 
| 275 302 | 
             
                  # @return [WorkflowUpdateHandle] The update handle.
         | 
| @@ -285,15 +312,20 @@ module Temporalio | |
| 285 312 | 
             
                    *args,
         | 
| 286 313 | 
             
                    wait_for_stage:,
         | 
| 287 314 | 
             
                    id: SecureRandom.uuid,
         | 
| 315 | 
            +
                    arg_hints: nil,
         | 
| 316 | 
            +
                    result_hint: nil,
         | 
| 288 317 | 
             
                    rpc_options: nil
         | 
| 289 318 | 
             
                  )
         | 
| 319 | 
            +
                    update, defn_arg_hints, defn_result_hint = Workflow::Definition::Update._name_and_hints_from_parameter(update)
         | 
| 290 320 | 
             
                    @client._impl.start_workflow_update(Interceptor::StartWorkflowUpdateInput.new(
         | 
| 291 321 | 
             
                                                          workflow_id: self.id,
         | 
| 292 322 | 
             
                                                          run_id:,
         | 
| 293 323 | 
             
                                                          update_id: id,
         | 
| 294 | 
            -
                                                          update | 
| 324 | 
            +
                                                          update:,
         | 
| 295 325 | 
             
                                                          args:,
         | 
| 296 326 | 
             
                                                          wait_for_stage:,
         | 
| 327 | 
            +
                                                          arg_hints: arg_hints || defn_arg_hints,
         | 
| 328 | 
            +
                                                          result_hint: result_hint || defn_result_hint,
         | 
| 297 329 | 
             
                                                          headers: {},
         | 
| 298 330 | 
             
                                                          rpc_options:
         | 
| 299 331 | 
             
                                                        ))
         | 
| @@ -305,6 +337,10 @@ module Temporalio | |
| 305 337 | 
             
                  # @param update [Workflow::Definition::Update, Symbol, String] Update definition or name.
         | 
| 306 338 | 
             
                  # @param args [Array<Object>] Update arguments.
         | 
| 307 339 | 
             
                  # @param id [String] ID of the update.
         | 
| 340 | 
            +
                  # @param arg_hints [Array<Object>, nil] Update argument hints. If unset/nil and am update definition is passed,
         | 
| 341 | 
            +
                  #   uses the ones on the update definition if present.
         | 
| 342 | 
            +
                  # @param result_hint [Object, nil] Update result hints. If unset/nil and an update definition is passed, uses the
         | 
| 343 | 
            +
                  #   one on the update definition if present.
         | 
| 308 344 | 
             
                  # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 309 345 | 
             
                  #
         | 
| 310 346 | 
             
                  # @return [Object, nil] Update result.
         | 
| @@ -316,12 +352,14 @@ module Temporalio | |
| 316 352 | 
             
                  #
         | 
| 317 353 | 
             
                  # @note Handles created as a result of {Client.start_workflow} will send updates the latest workflow with the same
         | 
| 318 354 | 
             
                  #   workflow ID even if it is unrelated to the started workflow.
         | 
| 319 | 
            -
                  def execute_update(update, *args, id: SecureRandom.uuid, rpc_options: nil)
         | 
| 355 | 
            +
                  def execute_update(update, *args, id: SecureRandom.uuid, arg_hints: nil, result_hint: nil, rpc_options: nil)
         | 
| 320 356 | 
             
                    start_update(
         | 
| 321 357 | 
             
                      update,
         | 
| 322 358 | 
             
                      *args,
         | 
| 323 359 | 
             
                      wait_for_stage: WorkflowUpdateWaitStage::COMPLETED,
         | 
| 324 360 | 
             
                      id:,
         | 
| 361 | 
            +
                      arg_hints:,
         | 
| 362 | 
            +
                      result_hint:,
         | 
| 325 363 | 
             
                      rpc_options:
         | 
| 326 364 | 
             
                    ).result
         | 
| 327 365 | 
             
                  end
         | 
| @@ -331,15 +369,17 @@ module Temporalio | |
| 331 369 | 
             
                  # @param id [String] ID of the update.
         | 
| 332 370 | 
             
                  # @param specific_run_id [String, nil] Workflow run ID to get update handle for. Default is the {run_id}. Most
         | 
| 333 371 | 
             
                  #   users will not need to set this and instead use the one on the class.
         | 
| 372 | 
            +
                  # @param result_hint [Object, nil] Result hint for the update result to set on the handle.
         | 
| 334 373 | 
             
                  #
         | 
| 335 374 | 
             
                  # @return [WorkflowUpdateHandle] The update handle.
         | 
| 336 | 
            -
                  def update_handle(id, specific_run_id: run_id)
         | 
| 375 | 
            +
                  def update_handle(id, specific_run_id: run_id, result_hint: nil)
         | 
| 337 376 | 
             
                    WorkflowUpdateHandle.new(
         | 
| 338 377 | 
             
                      client: @client,
         | 
| 339 378 | 
             
                      id:,
         | 
| 340 379 | 
             
                      workflow_id: self.id,
         | 
| 341 380 | 
             
                      workflow_run_id: specific_run_id,
         | 
| 342 | 
            -
                      known_outcome: nil
         | 
| 381 | 
            +
                      known_outcome: nil,
         | 
| 382 | 
            +
                      result_hint:
         | 
| 343 383 | 
             
                    )
         | 
| 344 384 | 
             
                  end
         | 
| 345 385 |  | 
| @@ -18,13 +18,17 @@ module Temporalio | |
| 18 18 | 
             
                  # @return [String, nil] Run ID for the workflow.
         | 
| 19 19 | 
             
                  attr_reader :workflow_run_id
         | 
| 20 20 |  | 
| 21 | 
            +
                  # @return [Object, nil] Result hint if one set when the handle was created.
         | 
| 22 | 
            +
                  attr_reader :result_hint
         | 
| 23 | 
            +
             | 
| 21 24 | 
             
                  # @!visibility private
         | 
| 22 | 
            -
                  def initialize(client:, id:, workflow_id:, workflow_run_id:, known_outcome:)
         | 
| 25 | 
            +
                  def initialize(client:, id:, workflow_id:, workflow_run_id:, known_outcome:, result_hint:)
         | 
| 23 26 | 
             
                    @client = client
         | 
| 24 27 | 
             
                    @id = id
         | 
| 25 28 | 
             
                    @workflow_id = workflow_id
         | 
| 26 29 | 
             
                    @workflow_run_id = workflow_run_id
         | 
| 27 30 | 
             
                    @known_outcome = known_outcome
         | 
| 31 | 
            +
                    @result_hint = result_hint
         | 
| 28 32 | 
             
                  end
         | 
| 29 33 |  | 
| 30 34 | 
             
                  # @return [Boolean] True if the result is already known and {result} will not make a blocking call, false if
         | 
| @@ -36,6 +40,7 @@ module Temporalio | |
| 36 40 | 
             
                  # Wait for and return the result of the update. The result may already be known in which case no network call is
         | 
| 37 41 | 
             
                  # made. Otherwise the result will be polled for until it is returned.
         | 
| 38 42 | 
             
                  #
         | 
| 43 | 
            +
                  # @param result_hint [Object, nil] If not nil, overrides handle-level result hint for getting the result.
         | 
| 39 44 | 
             
                  # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 40 45 | 
             
                  #
         | 
| 41 46 | 
             
                  # @return [Object, nil] Update result.
         | 
| @@ -44,7 +49,7 @@ module Temporalio | |
| 44 49 | 
             
                  # @raise [Error::WorkflowUpdateRPCTimeoutOrCanceledError] This update call timed out or was canceled. This doesn't
         | 
| 45 50 | 
             
                  #   mean the update itself was timed out or canceled.
         | 
| 46 51 | 
             
                  # @raise [Error::RPCError] RPC error from call.
         | 
| 47 | 
            -
                  def result(rpc_options: nil)
         | 
| 52 | 
            +
                  def result(result_hint: nil, rpc_options: nil)
         | 
| 48 53 | 
             
                    @known_outcome ||= @client._impl.poll_workflow_update(Interceptor::PollWorkflowUpdateInput.new(
         | 
| 49 54 | 
             
                                                                            workflow_id:,
         | 
| 50 55 | 
             
                                                                            run_id: workflow_run_id,
         | 
| @@ -56,7 +61,8 @@ module Temporalio | |
| 56 61 | 
             
                      raise Error::WorkflowUpdateFailedError.new, cause: @client.data_converter.from_failure(@known_outcome.failure)
         | 
| 57 62 | 
             
                    end
         | 
| 58 63 |  | 
| 59 | 
            -
                    results = @client.data_converter.from_payloads(@known_outcome.success | 
| 64 | 
            +
                    results = @client.data_converter.from_payloads(@known_outcome.success,
         | 
| 65 | 
            +
                                                                   hints: Array(result_hint || @result_hint))
         | 
| 60 66 | 
             
                    warn("Expected 0 or 1 update result, got #{results.size}") if results.size > 1
         | 
| 61 67 | 
             
                    results.first
         | 
| 62 68 | 
             
                  end
         | 
    
        data/lib/temporalio/client.rb
    CHANGED
    
    | @@ -19,9 +19,11 @@ require 'temporalio/common_enums' | |
| 19 19 | 
             
            require 'temporalio/converters'
         | 
| 20 20 | 
             
            require 'temporalio/error'
         | 
| 21 21 | 
             
            require 'temporalio/internal/client/implementation'
         | 
| 22 | 
            +
            require 'temporalio/priority'
         | 
| 22 23 | 
             
            require 'temporalio/retry_policy'
         | 
| 23 24 | 
             
            require 'temporalio/runtime'
         | 
| 24 25 | 
             
            require 'temporalio/search_attributes'
         | 
| 26 | 
            +
            require 'temporalio/versioning_override'
         | 
| 25 27 | 
             
            require 'temporalio/workflow/definition'
         | 
| 26 28 |  | 
| 27 29 | 
             
            module Temporalio
         | 
| @@ -48,6 +50,16 @@ module Temporalio | |
| 48 50 | 
             
                # Options as returned from {options} for +**to_h+ splat use in {initialize}. See {initialize} for details.
         | 
| 49 51 | 
             
                class Options; end # rubocop:disable Lint/EmptyClass
         | 
| 50 52 |  | 
| 53 | 
            +
                ListWorkflowPage = Data.define(:executions, :next_page_token)
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                # A page of workflow executions returned by {Client#list_workflow_page}.
         | 
| 56 | 
            +
                #
         | 
| 57 | 
            +
                # @!attribute executions
         | 
| 58 | 
            +
                #   @return [Array<WorkflowExecution>] List of workflow executions in this page.
         | 
| 59 | 
            +
                # @!attribute next_page_token
         | 
| 60 | 
            +
                #   @return [String, nil] Token for the next page of results. nil if there are no more results.
         | 
| 61 | 
            +
                class ListWorkflowPage; end # rubocop:disable Lint/EmptyClass
         | 
| 62 | 
            +
             | 
| 51 63 | 
             
                # Connect to Temporal server. This is a shortcut for +Connection.new+ followed by +Client.new+.
         | 
| 52 64 | 
             
                #
         | 
| 53 65 | 
             
                # @param target_host [String] +host:port+ for the Temporal server. For local development, this is often
         | 
| @@ -216,6 +228,13 @@ module Temporalio | |
| 216 228 | 
             
                #   with `cron_schedule`.
         | 
| 217 229 | 
             
                # @param request_eager_start [Boolean] Potentially reduce the latency to start this workflow by encouraging the
         | 
| 218 230 | 
             
                #   server to start it on a local worker running with this same client. This is currently experimental.
         | 
| 231 | 
            +
                # @param versioning_override [VersioningOverride, nil] Override the version of the workflow.
         | 
| 232 | 
            +
                #   This is currently experimental.
         | 
| 233 | 
            +
                # @param priority [Priority] Priority of the workflow. This is currently experimental.
         | 
| 234 | 
            +
                # @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
         | 
| 235 | 
            +
                #   workflow definition has arg hints, those are used by default.
         | 
| 236 | 
            +
                # @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the workflow
         | 
| 237 | 
            +
                #   definition has result hint, it is used by default.
         | 
| 219 238 | 
             
                # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 220 239 | 
             
                #
         | 
| 221 240 | 
             
                # @return [WorkflowHandle] A workflow handle to the started workflow.
         | 
| @@ -239,10 +258,17 @@ module Temporalio | |
| 239 258 | 
             
                  search_attributes: nil,
         | 
| 240 259 | 
             
                  start_delay: nil,
         | 
| 241 260 | 
             
                  request_eager_start: false,
         | 
| 261 | 
            +
                  versioning_override: nil,
         | 
| 262 | 
            +
                  priority: Priority.default,
         | 
| 263 | 
            +
                  arg_hints: nil,
         | 
| 264 | 
            +
                  result_hint: nil,
         | 
| 242 265 | 
             
                  rpc_options: nil
         | 
| 243 266 | 
             
                )
         | 
| 267 | 
            +
                  # Take hints from definition if there is a definition
         | 
| 268 | 
            +
                  workflow, defn_arg_hints, defn_result_hint =
         | 
| 269 | 
            +
                    Workflow::Definition._workflow_type_and_hints_from_workflow_parameter(workflow)
         | 
| 244 270 | 
             
                  @impl.start_workflow(Interceptor::StartWorkflowInput.new(
         | 
| 245 | 
            -
                                         workflow | 
| 271 | 
            +
                                         workflow:,
         | 
| 246 272 | 
             
                                         args:,
         | 
| 247 273 | 
             
                                         workflow_id: id,
         | 
| 248 274 | 
             
                                         task_queue:,
         | 
| @@ -260,6 +286,10 @@ module Temporalio | |
| 260 286 | 
             
                                         start_delay:,
         | 
| 261 287 | 
             
                                         request_eager_start:,
         | 
| 262 288 | 
             
                                         headers: {},
         | 
| 289 | 
            +
                                         versioning_override:,
         | 
| 290 | 
            +
                                         priority:,
         | 
| 291 | 
            +
                                         arg_hints: arg_hints || defn_arg_hints,
         | 
| 292 | 
            +
                                         result_hint: result_hint || defn_result_hint,
         | 
| 263 293 | 
             
                                         rpc_options:
         | 
| 264 294 | 
             
                                       ))
         | 
| 265 295 | 
             
                end
         | 
| @@ -292,6 +322,13 @@ module Temporalio | |
| 292 322 | 
             
                #   with `cron_schedule`.
         | 
| 293 323 | 
             
                # @param request_eager_start [Boolean] Potentially reduce the latency to start this workflow by encouraging the
         | 
| 294 324 | 
             
                #   server to start it on a local worker running with this same client. This is currently experimental.
         | 
| 325 | 
            +
                # @param versioning_override [VersioningOverride, nil] Override the version of the workflow.
         | 
| 326 | 
            +
                #   This is currently experimental.
         | 
| 327 | 
            +
                # @param priority [Priority] Priority for the workflow. This is currently experimental.
         | 
| 328 | 
            +
                # @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
         | 
| 329 | 
            +
                #   workflow definition has arg hints, those are used by default.
         | 
| 330 | 
            +
                # @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the workflow
         | 
| 331 | 
            +
                #   definition has result hint, it is used by default.
         | 
| 295 332 | 
             
                # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 296 333 | 
             
                #
         | 
| 297 334 | 
             
                # @return [Object] Successful result of the workflow.
         | 
| @@ -316,6 +353,10 @@ module Temporalio | |
| 316 353 | 
             
                  search_attributes: nil,
         | 
| 317 354 | 
             
                  start_delay: nil,
         | 
| 318 355 | 
             
                  request_eager_start: false,
         | 
| 356 | 
            +
                  versioning_override: nil,
         | 
| 357 | 
            +
                  priority: Priority.default,
         | 
| 358 | 
            +
                  arg_hints: nil,
         | 
| 359 | 
            +
                  result_hint: nil,
         | 
| 319 360 | 
             
                  rpc_options: nil
         | 
| 320 361 | 
             
                )
         | 
| 321 362 | 
             
                  start_workflow(
         | 
| @@ -336,6 +377,10 @@ module Temporalio | |
| 336 377 | 
             
                    search_attributes:,
         | 
| 337 378 | 
             
                    start_delay:,
         | 
| 338 379 | 
             
                    request_eager_start:,
         | 
| 380 | 
            +
                    versioning_override:,
         | 
| 381 | 
            +
                    priority:,
         | 
| 382 | 
            +
                    arg_hints:,
         | 
| 383 | 
            +
                    result_hint:,
         | 
| 339 384 | 
             
                    rpc_options:
         | 
| 340 385 | 
             
                  ).result
         | 
| 341 386 | 
             
                end
         | 
| @@ -347,14 +392,18 @@ module Temporalio | |
| 347 392 | 
             
                #   interactions occur on the latest of the workflow ID.
         | 
| 348 393 | 
             
                # @param first_execution_run_id [String, nil] First execution run ID used for some calls like cancellation and
         | 
| 349 394 | 
             
                #   termination to ensure the affected workflow is only within the same chain as this given run ID.
         | 
| 395 | 
            +
                # @param result_hint [Object, nil] Converter hint for the workflow's result.
         | 
| 350 396 | 
             
                #
         | 
| 351 397 | 
             
                # @return [WorkflowHandle] The workflow handle.
         | 
| 352 398 | 
             
                def workflow_handle(
         | 
| 353 399 | 
             
                  workflow_id,
         | 
| 354 400 | 
             
                  run_id: nil,
         | 
| 355 | 
            -
                  first_execution_run_id: nil
         | 
| 401 | 
            +
                  first_execution_run_id: nil,
         | 
| 402 | 
            +
                  result_hint: nil
         | 
| 356 403 | 
             
                )
         | 
| 357 | 
            -
                  WorkflowHandle.new( | 
| 404 | 
            +
                  WorkflowHandle.new(
         | 
| 405 | 
            +
                    client: self, id: workflow_id, run_id:, result_run_id: run_id, first_execution_run_id:, result_hint:
         | 
| 406 | 
            +
                  )
         | 
| 358 407 | 
             
                end
         | 
| 359 408 |  | 
| 360 409 | 
             
                # Start an update, possibly starting the workflow at the same time if it doesn't exist (depending upon ID conflict
         | 
| @@ -368,6 +417,10 @@ module Temporalio | |
| 368 417 | 
             
                # @param wait_for_stage [WorkflowUpdateWaitStage] Required stage to wait until returning. ADMITTED is not
         | 
| 369 418 | 
             
                #   currently supported. See https://docs.temporal.io/workflows#update for more details.
         | 
| 370 419 | 
             
                # @param id [String] ID of the update.
         | 
| 420 | 
            +
                # @param arg_hints [Array<Object>, nil] Overrides converter hints for update arguments if any. If unset/nil and the
         | 
| 421 | 
            +
                #   update definition has arg hints, those are used by default.
         | 
| 422 | 
            +
                # @param result_hint [Object, nil] Overrides converter hint for update result if any. If unset/nil and the update
         | 
| 423 | 
            +
                #   definition has result hint, it is used by default.
         | 
| 371 424 | 
             
                # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 372 425 | 
             
                #
         | 
| 373 426 | 
             
                # @return [WorkflowUpdateHandle] The update handle.
         | 
| @@ -381,15 +434,20 @@ module Temporalio | |
| 381 434 | 
             
                  start_workflow_operation:,
         | 
| 382 435 | 
             
                  wait_for_stage:,
         | 
| 383 436 | 
             
                  id: SecureRandom.uuid,
         | 
| 437 | 
            +
                  arg_hints: nil,
         | 
| 438 | 
            +
                  result_hint: nil,
         | 
| 384 439 | 
             
                  rpc_options: nil
         | 
| 385 440 | 
             
                )
         | 
| 441 | 
            +
                  update, defn_arg_hints, defn_result_hint = Workflow::Definition::Update._name_and_hints_from_parameter(update)
         | 
| 386 442 | 
             
                  @impl.start_update_with_start_workflow(
         | 
| 387 443 | 
             
                    Interceptor::StartUpdateWithStartWorkflowInput.new(
         | 
| 388 444 | 
             
                      update_id: id,
         | 
| 389 | 
            -
                      update | 
| 445 | 
            +
                      update:,
         | 
| 390 446 | 
             
                      args:,
         | 
| 391 447 | 
             
                      wait_for_stage:,
         | 
| 392 448 | 
             
                      start_workflow_operation:,
         | 
| 449 | 
            +
                      arg_hints: arg_hints || defn_arg_hints,
         | 
| 450 | 
            +
                      result_hint: result_hint || defn_result_hint,
         | 
| 393 451 | 
             
                      headers: {},
         | 
| 394 452 | 
             
                      rpc_options:
         | 
| 395 453 | 
             
                    )
         | 
| @@ -405,6 +463,10 @@ module Temporalio | |
| 405 463 | 
             
                # @param start_workflow_operation [WithStartWorkflowOperation] Required with-start workflow operation. This must
         | 
| 406 464 | 
             
                #   have an `id_conflict_policy` set.
         | 
| 407 465 | 
             
                # @param id [String] ID of the update.
         | 
| 466 | 
            +
                # @param arg_hints [Array<Object>, nil] Overrides converter hints for update arguments if any. If unset/nil and the
         | 
| 467 | 
            +
                #   update definition has arg hints, those are used by default.
         | 
| 468 | 
            +
                # @param result_hint [Object, nil] Overrides converter hint for update result if any. If unset/nil and the update
         | 
| 469 | 
            +
                #   definition has result hint, it is used by default.
         | 
| 408 470 | 
             
                # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 409 471 | 
             
                #
         | 
| 410 472 | 
             
                # @return [Object] Successful update result.
         | 
| @@ -418,6 +480,8 @@ module Temporalio | |
| 418 480 | 
             
                  *args,
         | 
| 419 481 | 
             
                  start_workflow_operation:,
         | 
| 420 482 | 
             
                  id: SecureRandom.uuid,
         | 
| 483 | 
            +
                  arg_hints: nil,
         | 
| 484 | 
            +
                  result_hint: nil,
         | 
| 421 485 | 
             
                  rpc_options: nil
         | 
| 422 486 | 
             
                )
         | 
| 423 487 | 
             
                  start_update_with_start_workflow(
         | 
| @@ -426,6 +490,8 @@ module Temporalio | |
| 426 490 | 
             
                    start_workflow_operation:,
         | 
| 427 491 | 
             
                    wait_for_stage: WorkflowUpdateWaitStage::COMPLETED,
         | 
| 428 492 | 
             
                    id:,
         | 
| 493 | 
            +
                    arg_hints:,
         | 
| 494 | 
            +
                    result_hint:,
         | 
| 429 495 | 
             
                    rpc_options:
         | 
| 430 496 | 
             
                  ).result
         | 
| 431 497 | 
             
                end
         | 
| @@ -436,6 +502,8 @@ module Temporalio | |
| 436 502 | 
             
                # @param args [Array<Object>] Signal arguments.
         | 
| 437 503 | 
             
                # @param start_workflow_operation [WithStartWorkflowOperation] Required with-start workflow operation. This may not
         | 
| 438 504 | 
             
                #   support all `id_conflict_policy` options.
         | 
| 505 | 
            +
                # @param arg_hints [Array<Object>, nil] Overrides converter hints for signal arguments if any. If unset/nil and the
         | 
| 506 | 
            +
                #   signal definition has arg hints, those are used by default.
         | 
| 439 507 | 
             
                # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 440 508 | 
             
                #
         | 
| 441 509 | 
             
                # @return [WorkflowHandle] A workflow handle to the workflow.
         | 
| @@ -445,13 +513,16 @@ module Temporalio | |
| 445 513 | 
             
                  signal,
         | 
| 446 514 | 
             
                  *args,
         | 
| 447 515 | 
             
                  start_workflow_operation:,
         | 
| 516 | 
            +
                  arg_hints: nil,
         | 
| 448 517 | 
             
                  rpc_options: nil
         | 
| 449 518 | 
             
                )
         | 
| 519 | 
            +
                  signal, defn_arg_hints = Workflow::Definition::Signal._name_and_hints_from_parameter(signal)
         | 
| 450 520 | 
             
                  @impl.signal_with_start_workflow(
         | 
| 451 521 | 
             
                    Interceptor::SignalWithStartWorkflowInput.new(
         | 
| 452 | 
            -
                      signal | 
| 522 | 
            +
                      signal:,
         | 
| 453 523 | 
             
                      args:,
         | 
| 454 524 | 
             
                      start_workflow_operation:,
         | 
| 525 | 
            +
                      arg_hints: arg_hints || defn_arg_hints,
         | 
| 455 526 | 
             
                      rpc_options:
         | 
| 456 527 | 
             
                    )
         | 
| 457 528 | 
             
                  )
         | 
| @@ -468,7 +539,40 @@ module Temporalio | |
| 468 539 | 
             
                #
         | 
| 469 540 | 
             
                # @see https://docs.temporal.io/visibility
         | 
| 470 541 | 
             
                def list_workflows(query = nil, rpc_options: nil)
         | 
| 471 | 
            -
                   | 
| 542 | 
            +
                  next_page_token = nil
         | 
| 543 | 
            +
                  Enumerator.new do |yielder|
         | 
| 544 | 
            +
                    loop do
         | 
| 545 | 
            +
                      list_workflow_page_input = Interceptor::ListWorkflowPageInput.new(
         | 
| 546 | 
            +
                        query: query,
         | 
| 547 | 
            +
                        rpc_options: rpc_options,
         | 
| 548 | 
            +
                        next_page_token: next_page_token,
         | 
| 549 | 
            +
                        page_size: nil
         | 
| 550 | 
            +
                      )
         | 
| 551 | 
            +
                      page = @impl.list_workflow_page(list_workflow_page_input)
         | 
| 552 | 
            +
                      page.executions.each { |execution| yielder << execution }
         | 
| 553 | 
            +
                      next_page_token = page.next_page_token
         | 
| 554 | 
            +
                      break if (next_page_token || '').empty?
         | 
| 555 | 
            +
                    end
         | 
| 556 | 
            +
                  end
         | 
| 557 | 
            +
                end
         | 
| 558 | 
            +
             | 
| 559 | 
            +
                # List workflows one page at a time.
         | 
| 560 | 
            +
                #
         | 
| 561 | 
            +
                # @param query [String, nil] A Temporal visibility list filter.
         | 
| 562 | 
            +
                # @param page_size [Integer, nil] Maximum number of results to return.
         | 
| 563 | 
            +
                # @param next_page_token [String, nil] Token for the next page of results. If not set, the first page is returned.
         | 
| 564 | 
            +
                # @param rpc_options [RPCOptions, nil] Advanced RPC options.
         | 
| 565 | 
            +
                #
         | 
| 566 | 
            +
                # @return [ListWorkflowPage] Page of workflow executions, along with a next_page_token to keep fetching.
         | 
| 567 | 
            +
                #
         | 
| 568 | 
            +
                # @raise [Error::RPCError] RPC error from call.
         | 
| 569 | 
            +
                #
         | 
| 570 | 
            +
                # @see https://docs.temporal.io/visibility
         | 
| 571 | 
            +
                def list_workflow_page(query = nil, page_size: nil, next_page_token: nil, rpc_options: nil)
         | 
| 572 | 
            +
                  @impl.list_workflow_page(Interceptor::ListWorkflowPageInput.new(query:,
         | 
| 573 | 
            +
                                                                                  next_page_token:,
         | 
| 574 | 
            +
                                                                                  page_size:,
         | 
| 575 | 
            +
                                                                                  rpc_options:))
         | 
| 472 576 | 
             
                end
         | 
| 473 577 |  | 
| 474 578 | 
             
                # Count workflows.
         | 
| @@ -38,4 +38,18 @@ module Temporalio | |
| 38 38 | 
             
                # Terminate the running workflow before starting a new one.
         | 
| 39 39 | 
             
                TERMINATE_EXISTING = Api::Enums::V1::WorkflowIdConflictPolicy::WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING
         | 
| 40 40 | 
             
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              # Specifies when a workflow might move from a worker of one Build Id to another.
         | 
| 43 | 
            +
              #
         | 
| 44 | 
            +
              # WARNING: Experimental API.
         | 
| 45 | 
            +
              module VersioningBehavior
         | 
| 46 | 
            +
                # Unspecified versioning behavior. By default, workers opting into worker versioning will
         | 
| 47 | 
            +
                # be required to specify a behavior.
         | 
| 48 | 
            +
                UNSPECIFIED = Api::Enums::V1::VersioningBehavior::VERSIONING_BEHAVIOR_UNSPECIFIED
         | 
| 49 | 
            +
                # The workflow will be pinned to the current Build ID unless manually moved.
         | 
| 50 | 
            +
                PINNED = Api::Enums::V1::VersioningBehavior::VERSIONING_BEHAVIOR_PINNED
         | 
| 51 | 
            +
                # The workflow will automatically move to the latest version (default Build ID of the task
         | 
| 52 | 
            +
                # queue) when the next task is dispatched.
         | 
| 53 | 
            +
                AUTO_UPGRADE = Api::Enums::V1::VersioningBehavior::VERSIONING_BEHAVIOR_AUTO_UPGRADE
         | 
| 54 | 
            +
              end
         | 
| 41 55 | 
             
            end
         | 
| @@ -452,16 +452,16 @@ module Temporalio | |
| 452 452 | 
             
                      attributes = { 'temporalWorkflowID' => Temporalio::Workflow.info.workflow_id,
         | 
| 453 453 | 
             
                                     'temporalRunID' => Temporalio::Workflow.info.run_id }.merge(attributes)
         | 
| 454 454 |  | 
| 455 | 
            -
                       | 
| 456 | 
            -
                      #  | 
| 457 | 
            -
                       | 
| 458 | 
            -
             | 
| 459 | 
            -
             | 
| 460 | 
            -
                        span = root.tracer.start_span(name, attributes:, links:, start_timestamp:  | 
| 455 | 
            +
                      time = Temporalio::Workflow.now.dup
         | 
| 456 | 
            +
                      # Disable durable scheduler because 1) synchronous/non-batch span processors in OTel use network (though could
         | 
| 457 | 
            +
                      # have just used Unafe.io_enabled for this if not for the next point) and 2) OTel uses Ruby Timeout which we
         | 
| 458 | 
            +
                      # don't want to use durable timers.
         | 
| 459 | 
            +
                      Temporalio::Workflow::Unsafe.durable_scheduler_disabled do
         | 
| 460 | 
            +
                        span = root.tracer.start_span(name, attributes:, links:, start_timestamp: time, kind:) # steep:ignore
         | 
| 461 461 | 
             
                        # Record exception if present
         | 
| 462 462 | 
             
                        span.record_exception(exception) if exception
         | 
| 463 463 | 
             
                        # Finish the span (returns self)
         | 
| 464 | 
            -
                        span.finish(end_timestamp:  | 
| 464 | 
            +
                        span.finish(end_timestamp: time)
         | 
| 465 465 | 
             
                      end
         | 
| 466 466 | 
             
                    end
         | 
| 467 467 | 
             
                  end
         | 
| @@ -40,9 +40,10 @@ module Temporalio | |
| 40 40 | 
             
                  # Convert a Ruby value to a payload and encode it.
         | 
| 41 41 | 
             
                  #
         | 
| 42 42 | 
             
                  # @param value [Object] Ruby value.
         | 
| 43 | 
            +
                  # @param hint [Object, nil] Hint, if any, to assist conversion.
         | 
| 43 44 | 
             
                  # @return [Api::Common::V1::Payload] Converted and encoded payload.
         | 
| 44 | 
            -
                  def to_payload(value)
         | 
| 45 | 
            -
                    payload = payload_converter.to_payload(value)
         | 
| 45 | 
            +
                  def to_payload(value, hint: nil)
         | 
| 46 | 
            +
                    payload = payload_converter.to_payload(value, hint:)
         | 
| 46 47 | 
             
                    payload = payload_codec.encode([payload]).first if payload_codec
         | 
| 47 48 | 
             
                    payload
         | 
| 48 49 | 
             
                  end
         | 
| @@ -50,9 +51,13 @@ module Temporalio | |
| 50 51 | 
             
                  # Convert multiple Ruby values to a payload set and encode it.
         | 
| 51 52 | 
             
                  #
         | 
| 52 53 | 
             
                  # @param values [Object] Ruby values, converted to array via {::Array}.
         | 
| 54 | 
            +
                  # @param hints [Array<Object>, nil] Hints, if any, to assist conversion. Note, when using the default converter
         | 
| 55 | 
            +
                  #   that converts a payload at a time, hints for each value are taken from the array at that value's index. So if
         | 
| 56 | 
            +
                  #   there are fewer hints than values, some values will not have a hint. Similarly if there are more hints than
         | 
| 57 | 
            +
                  #   values, the trailing hints are not used.
         | 
| 53 58 | 
             
                  # @return [Api::Common::V1::Payloads] Converted and encoded payload set.
         | 
| 54 | 
            -
                  def to_payloads(values)
         | 
| 55 | 
            -
                    payloads = payload_converter.to_payloads(values)
         | 
| 59 | 
            +
                  def to_payloads(values, hints: nil)
         | 
| 60 | 
            +
                    payloads = payload_converter.to_payloads(values, hints:)
         | 
| 56 61 | 
             
                    payloads.payloads.replace(payload_codec.encode(payloads.payloads)) if payload_codec && !payloads.payloads.empty?
         | 
| 57 62 | 
             
                    payloads
         | 
| 58 63 | 
             
                  end
         | 
| @@ -60,23 +65,28 @@ module Temporalio | |
| 60 65 | 
             
                  # Decode and convert a payload to a Ruby value.
         | 
| 61 66 | 
             
                  #
         | 
| 62 67 | 
             
                  # @param payload [Api::Common::V1::Payload] Encoded payload.
         | 
| 68 | 
            +
                  # @param hint [Object, nil] Hint, if any, to assist conversion.
         | 
| 63 69 | 
             
                  # @return [Object] Decoded and converted Ruby value.
         | 
| 64 | 
            -
                  def from_payload(payload)
         | 
| 70 | 
            +
                  def from_payload(payload, hint: nil)
         | 
| 65 71 | 
             
                    payload = payload_codec.decode([payload]).first if payload_codec
         | 
| 66 | 
            -
                    payload_converter.from_payload(payload)
         | 
| 72 | 
            +
                    payload_converter.from_payload(payload, hint:)
         | 
| 67 73 | 
             
                  end
         | 
| 68 74 |  | 
| 69 75 | 
             
                  # Decode and convert a payload set to Ruby values.
         | 
| 70 76 | 
             
                  #
         | 
| 71 77 | 
             
                  # @param payloads [Api::Common::V1::Payloads, nil] Encoded payload set.
         | 
| 78 | 
            +
                  # @param hints [Array<Object>, nil] Hints, if any, to assist conversion. Note, when using the default converter
         | 
| 79 | 
            +
                  #   that converts a value at a time, hints for each payload are taken from the array at that payload's index. So
         | 
| 80 | 
            +
                  #   if there are fewer hints than payloads, some payloads will not have a hint. Similarly if there are more hints
         | 
| 81 | 
            +
                  #   than payloads, the trailing hints are not used.
         | 
| 72 82 | 
             
                  # @return [Array<Object>] Decoded and converted Ruby values.
         | 
| 73 | 
            -
                  def from_payloads(payloads)
         | 
| 83 | 
            +
                  def from_payloads(payloads, hints: nil)
         | 
| 74 84 | 
             
                    return [] unless payloads && !payloads.payloads.empty?
         | 
| 75 85 |  | 
| 76 86 | 
             
                    if payload_codec && !payloads.payloads.empty?
         | 
| 77 87 | 
             
                      payloads = Api::Common::V1::Payloads.new(payloads: payload_codec.decode(payloads.payloads))
         | 
| 78 88 | 
             
                    end
         | 
| 79 | 
            -
                    payload_converter.from_payloads(payloads)
         | 
| 89 | 
            +
                    payload_converter.from_payloads(payloads, hints:)
         | 
| 80 90 | 
             
                  end
         | 
| 81 91 |  | 
| 82 92 | 
             
                  # Convert a Ruby error to a Temporal failure and encode it.
         | 
| @@ -45,7 +45,8 @@ module Temporalio | |
| 45 45 | 
             
                        type: error.type,
         | 
| 46 46 | 
             
                        non_retryable: error.non_retryable,
         | 
| 47 47 | 
             
                        details: converter.to_payloads(error.details),
         | 
| 48 | 
            -
                        next_retry_delay: Internal::ProtoUtils.seconds_to_duration(error.next_retry_delay)
         | 
| 48 | 
            +
                        next_retry_delay: Internal::ProtoUtils.seconds_to_duration(error.next_retry_delay),
         | 
| 49 | 
            +
                        category: error.category
         | 
| 49 50 | 
             
                      )
         | 
| 50 51 | 
             
                    when Error::TimeoutError
         | 
| 51 52 | 
             
                      failure.timeout_failure_info = Api::Failure::V1::TimeoutFailureInfo.new(
         | 
| @@ -85,7 +86,7 @@ module Temporalio | |
| 85 86 | 
             
                      )
         | 
| 86 87 | 
             
                    else
         | 
| 87 88 | 
             
                      failure.application_failure_info = Api::Failure::V1::ApplicationFailureInfo.new(
         | 
| 88 | 
            -
                        type: error.class.name
         | 
| 89 | 
            +
                        type: error.class.name.to_s.split('::').last
         | 
| 89 90 | 
             
                      )
         | 
| 90 91 | 
             
                    end
         | 
| 91 92 |  | 
| @@ -132,7 +133,9 @@ module Temporalio | |
| 132 133 | 
             
                                non_retryable: failure.application_failure_info.non_retryable,
         | 
| 133 134 | 
             
                                next_retry_delay: Internal::ProtoUtils.duration_to_seconds(
         | 
| 134 135 | 
             
                                  failure.application_failure_info.next_retry_delay
         | 
| 135 | 
            -
                                )
         | 
| 136 | 
            +
                                ),
         | 
| 137 | 
            +
                                category: Internal::ProtoUtils.enum_to_int(Api::Enums::V1::ApplicationErrorCategory,
         | 
| 138 | 
            +
                                                                           failure.application_failure_info.category)
         | 
| 136 139 | 
             
                              )
         | 
| 137 140 | 
             
                            elsif failure.timeout_failure_info
         | 
| 138 141 | 
             
                              Error::TimeoutError.new(
         | 
| @@ -16,7 +16,7 @@ module Temporalio | |
| 16 16 | 
             
                    end
         | 
| 17 17 |  | 
| 18 18 | 
             
                    # (see Encoding.to_payload)
         | 
| 19 | 
            -
                    def to_payload(value)
         | 
| 19 | 
            +
                    def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument
         | 
| 20 20 | 
             
                      return nil unless value.nil?
         | 
| 21 21 |  | 
| 22 22 | 
             
                      Api::Common::V1::Payload.new(
         | 
| @@ -25,7 +25,7 @@ module Temporalio | |
| 25 25 | 
             
                    end
         | 
| 26 26 |  | 
| 27 27 | 
             
                    # (see Encoding.from_payload)
         | 
| 28 | 
            -
                    def from_payload(payload) # rubocop:disable Lint/UnusedMethodArgument
         | 
| 28 | 
            +
                    def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument
         | 
| 29 29 | 
             
                      nil
         | 
| 30 30 | 
             
                    end
         | 
| 31 31 | 
             
                  end
         | 
| @@ -16,7 +16,7 @@ module Temporalio | |
| 16 16 | 
             
                    end
         | 
| 17 17 |  | 
| 18 18 | 
             
                    # (see Encoding.to_payload)
         | 
| 19 | 
            -
                    def to_payload(value)
         | 
| 19 | 
            +
                    def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument
         | 
| 20 20 | 
             
                      return nil unless value.is_a?(String) && value.encoding == ::Encoding::ASCII_8BIT
         | 
| 21 21 |  | 
| 22 22 | 
             
                      Temporalio::Api::Common::V1::Payload.new(
         | 
| @@ -26,7 +26,7 @@ module Temporalio | |
| 26 26 | 
             
                    end
         | 
| 27 27 |  | 
| 28 28 | 
             
                    # (see Encoding.from_payload)
         | 
| 29 | 
            -
                    def from_payload(payload)
         | 
| 29 | 
            +
                    def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument
         | 
| 30 30 | 
             
                      payload.data
         | 
| 31 31 | 
             
                    end
         | 
| 32 32 | 
             
                  end
         |