temporalio 1.2.0 → 1.4.0

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/Cargo.lock +985 -773
  4. data/Cargo.toml +16 -11
  5. data/Gemfile +0 -1
  6. data/README.md +4 -0
  7. data/Rakefile +12 -13
  8. data/ext/Cargo.toml +7 -3
  9. data/lib/temporalio/api/activity/v1/message.rb +5 -1
  10. data/lib/temporalio/api/callback/v1/message.rb +26 -0
  11. data/lib/temporalio/api/cloud/account/v1/message.rb +4 -1
  12. data/lib/temporalio/api/cloud/auditlog/v1/message.rb +27 -0
  13. data/lib/temporalio/api/cloud/billing/v1/message.rb +30 -0
  14. data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +23 -1
  15. data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +2 -1
  16. data/lib/temporalio/api/cloud/namespace/v1/message.rb +16 -2
  17. data/lib/temporalio/api/command/v1/message.rb +1 -1
  18. data/lib/temporalio/api/common/v1/message.rb +5 -1
  19. data/lib/temporalio/api/compute/v1/config.rb +30 -0
  20. data/lib/temporalio/api/compute/v1/provider.rb +23 -0
  21. data/lib/temporalio/api/compute/v1/scaler.rb +23 -0
  22. data/lib/temporalio/api/deployment/v1/message.rb +3 -1
  23. data/lib/temporalio/api/enums/v1/deployment.rb +1 -1
  24. data/lib/temporalio/api/enums/v1/event_type.rb +1 -1
  25. data/lib/temporalio/api/enums/v1/nexus.rb +5 -1
  26. data/lib/temporalio/api/enums/v1/task_queue.rb +1 -1
  27. data/lib/temporalio/api/enums/v1/workflow.rb +1 -1
  28. data/lib/temporalio/api/errordetails/v1/message.rb +2 -1
  29. data/lib/temporalio/api/failure/v1/message.rb +1 -1
  30. data/lib/temporalio/api/history/v1/message.rb +3 -1
  31. data/lib/temporalio/api/namespace/v1/message.rb +1 -1
  32. data/lib/temporalio/api/nexus/v1/message.rb +9 -1
  33. data/lib/temporalio/api/nexusservices/workerservice/v1/request_response.rb +26 -0
  34. data/lib/temporalio/api/payload_visitor.rb +174 -4
  35. data/lib/temporalio/api/protoc_gen_openapiv2/options/annotations.rb +23 -0
  36. data/lib/temporalio/api/protoc_gen_openapiv2/options/openapiv2.rb +48 -0
  37. data/lib/temporalio/api/protometa/v1/annotations.rb +23 -0
  38. data/lib/temporalio/api/sdk/v1/external_storage.rb +21 -0
  39. data/lib/temporalio/api/taskqueue/v1/message.rb +2 -1
  40. data/lib/temporalio/api/worker/v1/message.rb +7 -1
  41. data/lib/temporalio/api/workflow/v1/message.rb +2 -1
  42. data/lib/temporalio/api/workflowservice/v1/request_response.rb +31 -1
  43. data/lib/temporalio/api/workflowservice/v1/service.rb +2 -1
  44. data/lib/temporalio/client/connection/cloud_service.rb +150 -0
  45. data/lib/temporalio/client/connection/workflow_service.rb +195 -0
  46. data/lib/temporalio/client.rb +1 -3
  47. data/lib/temporalio/common_enums.rb +29 -2
  48. data/lib/temporalio/contrib/open_telemetry.rb +59 -13
  49. data/lib/temporalio/converters/failure_converter.rb +30 -0
  50. data/lib/temporalio/converters/payload_converter/composite.rb +4 -2
  51. data/lib/temporalio/env_config.rb +1 -3
  52. data/lib/temporalio/error/failure.rb +66 -0
  53. data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +1 -1
  54. data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +1 -1
  55. data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +1 -1
  56. data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +1 -1
  57. data/lib/temporalio/internal/bridge/client.rb +5 -10
  58. data/lib/temporalio/internal/bridge/runtime.rb +6 -12
  59. data/lib/temporalio/internal/bridge/testing.rb +2 -4
  60. data/lib/temporalio/internal/bridge/worker.rb +8 -16
  61. data/lib/temporalio/internal/bridge.rb +2 -2
  62. data/lib/temporalio/internal/client/implementation.rb +1 -1
  63. data/lib/temporalio/internal/proto_utils.rb +7 -5
  64. data/lib/temporalio/internal/worker/workflow_instance/context.rb +16 -1
  65. data/lib/temporalio/internal/worker/workflow_instance/nexus_client.rb +45 -0
  66. data/lib/temporalio/internal/worker/workflow_instance/nexus_operation_handle.rb +51 -0
  67. data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +71 -1
  68. data/lib/temporalio/internal/worker/workflow_instance.rb +20 -2
  69. data/lib/temporalio/search_attributes.rb +12 -2
  70. data/lib/temporalio/testing/workflow_environment.rb +40 -0
  71. data/lib/temporalio/version.rb +1 -1
  72. data/lib/temporalio/versioning_override.rb +0 -2
  73. data/lib/temporalio/worker/deployment_options.rb +0 -2
  74. data/lib/temporalio/worker/interceptor.rb +29 -0
  75. data/lib/temporalio/worker/workflow_executor/thread_pool.rb +1 -1
  76. data/lib/temporalio/worker/workflow_replayer.rb +1 -3
  77. data/lib/temporalio/worker.rb +9 -8
  78. data/lib/temporalio/worker_deployment_version.rb +0 -2
  79. data/lib/temporalio/workflow/definition.rb +0 -3
  80. data/lib/temporalio/workflow/info.rb +3 -6
  81. data/lib/temporalio/workflow/nexus_client.rb +93 -0
  82. data/lib/temporalio/workflow/nexus_operation_cancellation_type.rb +21 -0
  83. data/lib/temporalio/workflow/nexus_operation_handle.rb +37 -0
  84. data/lib/temporalio/workflow/update_info.rb +1 -2
  85. data/lib/temporalio/workflow.rb +34 -2
  86. metadata +18 -2
@@ -110,8 +110,6 @@ module Temporalio
110
110
 
111
111
  # Set the versioning behavior of this workflow.
112
112
  #
113
- # WARNING: This method is experimental and may change in future versions.
114
- #
115
113
  # @param behavior [VersioningBehavior] The versioning behavior.
116
114
  def workflow_versioning_behavior(behavior)
117
115
  @versioning_behavior = behavior
@@ -732,7 +730,6 @@ module Temporalio
732
730
  # @!attribute versioning_behavior
733
731
  # Dynamic equivalent of {Definition.workflow_versioning_behavior}.
734
732
  # Will override any behavior set there if set.
735
- # WARNING: Deployment-based versioning is experimental and APIs may change.
736
733
  # @return [VersioningBehavior, nil] The versioning behavior
737
734
  #
738
735
  # @return [VersioningBehavior, nil] The versioning behavior
@@ -23,8 +23,7 @@ module Temporalio
23
23
  :task_queue,
24
24
  :task_timeout,
25
25
  :workflow_id,
26
- :workflow_type,
27
- keyword_init: true
26
+ :workflow_type
28
27
  )
29
28
 
30
29
  # Information about the running workflow. This is immutable for the life of the workflow run.
@@ -91,8 +90,7 @@ module Temporalio
91
90
  ParentInfo = Struct.new(
92
91
  :namespace,
93
92
  :run_id,
94
- :workflow_id,
95
- keyword_init: true
93
+ :workflow_id
96
94
  )
97
95
 
98
96
  # Information about a root of a workflow.
@@ -106,8 +104,7 @@ module Temporalio
106
104
  # this class or it may break in incompatible ways.
107
105
  RootInfo = Struct.new(
108
106
  :run_id,
109
- :workflow_id,
110
- keyword_init: true
107
+ :workflow_id
111
108
  )
112
109
  end
113
110
  end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Temporalio
4
+ module Workflow
5
+ # Client for executing Nexus operations from workflows.
6
+ #
7
+ # This is created via {Workflow.create_nexus_client}, it is never instantiated directly.
8
+ #
9
+ # WARNING: Nexus support is experimental.
10
+ class NexusClient
11
+ # @!visibility private
12
+ def initialize
13
+ raise NotImplementedError, 'Cannot instantiate a Nexus client directly'
14
+ end
15
+
16
+ # @return [String] Endpoint name for this client.
17
+ def endpoint
18
+ raise NotImplementedError
19
+ end
20
+
21
+ # @return [String] Service name for this client.
22
+ def service
23
+ raise NotImplementedError
24
+ end
25
+
26
+ # Start a Nexus operation and return a handle.
27
+ #
28
+ # @param operation [Symbol, String] Operation name.
29
+ # @param arg [Object] Argument for the operation.
30
+ # @param schedule_to_close_timeout [Float, nil] Total timeout for the operation in seconds.
31
+ # @param schedule_to_start_timeout [Float, nil] Timeout in seconds for the operation to start executing. If the
32
+ # operation has not started within this window, a SCHEDULE_TO_START timeout error is raised.
33
+ # @param start_to_close_timeout [Float, nil] Timeout in seconds for an async operation to complete after it has
34
+ # started. If the operation does not complete within this window, a START_TO_CLOSE timeout error is raised.
35
+ # @param cancellation_type [NexusOperationCancellationType] How the operation will react to cancellation.
36
+ # @param summary [String, nil] Optional summary for the operation (appears in UI/CLI).
37
+ # @param cancellation [Cancellation] Cancellation for the operation.
38
+ # @param arg_hint [Object, nil] Converter hint for the argument.
39
+ # @param result_hint [Object, nil] Converter hint for the result.
40
+ # @return [NexusOperationHandle] Handle to the started operation.
41
+ def start_operation(
42
+ operation,
43
+ arg,
44
+ schedule_to_close_timeout: nil,
45
+ schedule_to_start_timeout: nil,
46
+ start_to_close_timeout: nil,
47
+ cancellation_type: NexusOperationCancellationType::WAIT_CANCELLATION_COMPLETED,
48
+ summary: nil,
49
+ cancellation: Workflow.cancellation,
50
+ arg_hint: nil,
51
+ result_hint: nil
52
+ )
53
+ raise NotImplementedError
54
+ end
55
+
56
+ # Execute a Nexus operation and wait for the result.
57
+ #
58
+ # This is a convenience method that calls {#start_operation} and immediately waits for the result.
59
+ #
60
+ # @param operation [Symbol, String] Operation name.
61
+ # @param arg [Object] Argument for the operation.
62
+ # @param schedule_to_close_timeout [Float, nil] Total timeout for the operation in seconds.
63
+ # @param schedule_to_start_timeout [Float, nil] Timeout in seconds for the operation to start executing. If the
64
+ # operation has not started within this window, a SCHEDULE_TO_START timeout error is raised.
65
+ # @param start_to_close_timeout [Float, nil] Timeout in seconds for an async operation to complete after it has
66
+ # started. If the operation does not complete within this window, a START_TO_CLOSE timeout error is raised.
67
+ # @param cancellation_type [NexusOperationCancellationType] How the operation will react to cancellation.
68
+ # @param summary [String, nil] Optional summary for the operation (appears in UI/CLI).
69
+ # @param cancellation [Cancellation] Cancellation for the operation.
70
+ # @param arg_hint [Object, nil] Converter hint for the argument.
71
+ # @param result_hint [Object, nil] Converter hint for the result.
72
+ # @return [Object] Result of the operation.
73
+ # @raise [Error::NexusOperationError] Operation failed.
74
+ def execute_operation(
75
+ operation,
76
+ arg,
77
+ schedule_to_close_timeout: nil,
78
+ schedule_to_start_timeout: nil,
79
+ start_to_close_timeout: nil,
80
+ cancellation_type: NexusOperationCancellationType::WAIT_CANCELLATION_COMPLETED,
81
+ summary: nil,
82
+ cancellation: Workflow.cancellation,
83
+ arg_hint: nil,
84
+ result_hint: nil
85
+ )
86
+ start_operation(
87
+ operation, arg, schedule_to_close_timeout:, schedule_to_start_timeout:, start_to_close_timeout:,
88
+ cancellation_type:, summary:, cancellation:, arg_hint:, result_hint:
89
+ ).result
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'temporalio/internal/bridge/api'
4
+
5
+ module Temporalio
6
+ module Workflow
7
+ # How a Nexus operation should handle cancellation.
8
+ #
9
+ # WARNING: Nexus support is experimental.
10
+ module NexusOperationCancellationType
11
+ # Wait for cancellation to complete (default).
12
+ WAIT_CANCELLATION_COMPLETED = Internal::Bridge::Api::Nexus::NexusOperationCancellationType::WAIT_CANCELLATION_COMPLETED
13
+ # Abandon the operation without sending a cancellation request.
14
+ ABANDON = Internal::Bridge::Api::Nexus::NexusOperationCancellationType::ABANDON
15
+ # Send a cancellation request but do not wait for confirmation.
16
+ TRY_CANCEL = Internal::Bridge::Api::Nexus::NexusOperationCancellationType::TRY_CANCEL
17
+ # Wait for the server to confirm the cancellation request was delivered.
18
+ WAIT_CANCELLATION_REQUESTED = Internal::Bridge::Api::Nexus::NexusOperationCancellationType::WAIT_CANCELLATION_REQUESTED
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Temporalio
4
+ module Workflow
5
+ # Handle for interacting with a Nexus operation.
6
+ #
7
+ # This is created via {NexusClient#start_operation}, it is never instantiated directly.
8
+ #
9
+ # WARNING: Nexus support is experimental.
10
+ class NexusOperationHandle
11
+ # @!visibility private
12
+ def initialize
13
+ raise NotImplementedError, 'Cannot instantiate a Nexus operation handle directly'
14
+ end
15
+
16
+ # @return [String, nil] Operation token for async operations, nil for sync operations.
17
+ def operation_token
18
+ raise NotImplementedError
19
+ end
20
+
21
+ # @return [Object, nil] Hint for the result if any.
22
+ def result_hint
23
+ raise NotImplementedError
24
+ end
25
+
26
+ # Wait for the result.
27
+ #
28
+ # @param result_hint [Object, nil] Override the result hint, or if nil uses the one on the handle.
29
+ # @return [Object] Result of the Nexus operation.
30
+ #
31
+ # @raise [Error::NexusOperationError] Operation failed with +cause+ as the cause.
32
+ def result(result_hint: nil)
33
+ raise NotImplementedError
34
+ end
35
+ end
36
+ end
37
+ end
@@ -13,8 +13,7 @@ module Temporalio
13
13
  # class or it may break in incompatible ways.
14
14
  UpdateInfo = Struct.new(
15
15
  :id,
16
- :name,
17
- keyword_init: true
16
+ :name
18
17
  )
19
18
  end
20
19
  end
@@ -12,6 +12,9 @@ require 'temporalio/workflow/external_workflow_handle'
12
12
  require 'temporalio/workflow/future'
13
13
  require 'temporalio/workflow/handler_unfinished_policy'
14
14
  require 'temporalio/workflow/info'
15
+ require 'temporalio/workflow/nexus_client'
16
+ require 'temporalio/workflow/nexus_operation_cancellation_type'
17
+ require 'temporalio/workflow/nexus_operation_handle'
15
18
  require 'temporalio/workflow/parent_close_policy'
16
19
  require 'temporalio/workflow/update_info'
17
20
  require 'timeout'
@@ -40,6 +43,29 @@ module Temporalio
40
43
  _current.continue_as_new_suggested
41
44
  end
42
45
 
46
+ # Create a Nexus client for executing operations.
47
+ #
48
+ # WARNING: Nexus support is experimental.
49
+ #
50
+ # @param endpoint [Symbol, String] Endpoint name.
51
+ # @param service [Symbol, String] Service name.
52
+ # @return [NexusClient] Client for executing Nexus operations.
53
+ def self.create_nexus_client(endpoint:, service:)
54
+ _current.create_nexus_client(endpoint:, service:)
55
+ end
56
+
57
+ # @return [Array<SuggestContinueAsNewReason::enum>] Reasons the server suggests continue-as-new. Empty if no
58
+ # suggestion. This is currently experimental.
59
+ def self.suggest_continue_as_new_reasons
60
+ _current.suggest_continue_as_new_reasons
61
+ end
62
+
63
+ # @return [Boolean] Whether the target worker deployment version has changed from the one this workflow is running
64
+ # on. This is currently experimental.
65
+ def self.target_worker_deployment_version_changed?
66
+ _current.target_worker_deployment_version_changed?
67
+ end
68
+
43
69
  # Get current details for this workflow that may appear in UI/CLI. Unlike static details set at start, this value
44
70
  # can be updated throughout the life of the workflow. This can be in Temporal markdown format and can span multiple
45
71
  # lines. This is currently experimental.
@@ -620,7 +646,8 @@ module Temporalio
620
646
  # Error that is raised by a workflow out of the primary workflow method to issue a continue-as-new.
621
647
  class ContinueAsNewError < Error
622
648
  attr_accessor :args, :workflow, :task_queue, :run_timeout, :task_timeout,
623
- :retry_policy, :memo, :search_attributes, :arg_hints, :headers
649
+ :retry_policy, :memo, :search_attributes, :arg_hints, :headers,
650
+ :initial_versioning_behavior
624
651
 
625
652
  # Create a continue as new error.
626
653
  #
@@ -643,6 +670,9 @@ module Temporalio
643
670
  # workflow definition has arg hints, those are used by default.
644
671
  # @param headers [Hash<String, Object>] Headers for the workflow. The default is _not_ carried over from the
645
672
  # current workflow.
673
+ # @param initial_versioning_behavior [ContinueAsNewVersioningBehavior::enum, nil] Versioning behavior for the
674
+ # first task of the new run. Set to {ContinueAsNewVersioningBehavior::AUTO_UPGRADE} to upgrade a pinned workflow
675
+ # to the latest version on continue-as-new. This is currently experimental.
646
676
  def initialize(
647
677
  *args,
648
678
  workflow: nil,
@@ -653,7 +683,8 @@ module Temporalio
653
683
  memo: nil,
654
684
  search_attributes: nil,
655
685
  arg_hints: nil,
656
- headers: {}
686
+ headers: {},
687
+ initial_versioning_behavior: nil
657
688
  )
658
689
  super('Continue as new')
659
690
  @args = args
@@ -666,6 +697,7 @@ module Temporalio
666
697
  @search_attributes = search_attributes
667
698
  @arg_hints = arg_hints
668
699
  @headers = headers
700
+ @initial_versioning_behavior = initial_versioning_behavior
669
701
  Workflow._current.initialize_continue_as_new_error(self)
670
702
  end
671
703
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temporalio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Temporal Technologies Inc
@@ -62,7 +62,10 @@ files:
62
62
  - lib/temporalio/api.rb
63
63
  - lib/temporalio/api/activity/v1/message.rb
64
64
  - lib/temporalio/api/batch/v1/message.rb
65
+ - lib/temporalio/api/callback/v1/message.rb
65
66
  - lib/temporalio/api/cloud/account/v1/message.rb
67
+ - lib/temporalio/api/cloud/auditlog/v1/message.rb
68
+ - lib/temporalio/api/cloud/billing/v1/message.rb
66
69
  - lib/temporalio/api/cloud/cloudservice.rb
67
70
  - lib/temporalio/api/cloud/cloudservice/v1/request_response.rb
68
71
  - lib/temporalio/api/cloud/cloudservice/v1/service.rb
@@ -78,6 +81,9 @@ files:
78
81
  - lib/temporalio/api/command/v1/message.rb
79
82
  - lib/temporalio/api/common/v1/grpc_status.rb
80
83
  - lib/temporalio/api/common/v1/message.rb
84
+ - lib/temporalio/api/compute/v1/config.rb
85
+ - lib/temporalio/api/compute/v1/provider.rb
86
+ - lib/temporalio/api/compute/v1/scaler.rb
81
87
  - lib/temporalio/api/deployment/v1/message.rb
82
88
  - lib/temporalio/api/enums/v1/activity.rb
83
89
  - lib/temporalio/api/enums/v1/batch_operation.rb
@@ -101,16 +107,21 @@ files:
101
107
  - lib/temporalio/api/history/v1/message.rb
102
108
  - lib/temporalio/api/namespace/v1/message.rb
103
109
  - lib/temporalio/api/nexus/v1/message.rb
110
+ - lib/temporalio/api/nexusservices/workerservice/v1/request_response.rb
104
111
  - lib/temporalio/api/operatorservice.rb
105
112
  - lib/temporalio/api/operatorservice/v1/request_response.rb
106
113
  - lib/temporalio/api/operatorservice/v1/service.rb
107
114
  - lib/temporalio/api/payload_visitor.rb
115
+ - lib/temporalio/api/protoc_gen_openapiv2/options/annotations.rb
116
+ - lib/temporalio/api/protoc_gen_openapiv2/options/openapiv2.rb
108
117
  - lib/temporalio/api/protocol/v1/message.rb
118
+ - lib/temporalio/api/protometa/v1/annotations.rb
109
119
  - lib/temporalio/api/query/v1/message.rb
110
120
  - lib/temporalio/api/replication/v1/message.rb
111
121
  - lib/temporalio/api/rules/v1/message.rb
112
122
  - lib/temporalio/api/schedule/v1/message.rb
113
123
  - lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb
124
+ - lib/temporalio/api/sdk/v1/external_storage.rb
114
125
  - lib/temporalio/api/sdk/v1/task_complete_metadata.rb
115
126
  - lib/temporalio/api/sdk/v1/user_metadata.rb
116
127
  - lib/temporalio/api/sdk/v1/worker_config.rb
@@ -197,6 +208,8 @@ files:
197
208
  - lib/temporalio/internal/worker/workflow_instance/handler_hash.rb
198
209
  - lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb
199
210
  - lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb
211
+ - lib/temporalio/internal/worker/workflow_instance/nexus_client.rb
212
+ - lib/temporalio/internal/worker/workflow_instance/nexus_operation_handle.rb
200
213
  - lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb
201
214
  - lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb
202
215
  - lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb
@@ -239,6 +252,9 @@ files:
239
252
  - lib/temporalio/workflow/future.rb
240
253
  - lib/temporalio/workflow/handler_unfinished_policy.rb
241
254
  - lib/temporalio/workflow/info.rb
255
+ - lib/temporalio/workflow/nexus_client.rb
256
+ - lib/temporalio/workflow/nexus_operation_cancellation_type.rb
257
+ - lib/temporalio/workflow/nexus_operation_handle.rb
242
258
  - lib/temporalio/workflow/parent_close_policy.rb
243
259
  - lib/temporalio/workflow/update_info.rb
244
260
  - lib/temporalio/workflow_history.rb
@@ -264,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
280
  - !ruby/object:Gem::Version
265
281
  version: '0'
266
282
  requirements: []
267
- rubygems_version: 4.0.3
283
+ rubygems_version: 4.0.6
268
284
  specification_version: 4
269
285
  summary: Temporal.io Ruby SDK
270
286
  test_files: []