temporalio 1.6.0 → 1.8.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 (120) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +37 -67
  3. data/Gemfile +3 -0
  4. data/README.md +25 -2
  5. data/Rakefile +20 -1
  6. data/ext/Cargo.toml +3 -3
  7. data/lib/temporalio/api/activity/v1/message.rb +1 -1
  8. data/lib/temporalio/api/batch/v1/message.rb +4 -1
  9. data/lib/temporalio/api/command/v1/message.rb +2 -1
  10. data/lib/temporalio/api/common/v1/message.rb +5 -1
  11. data/lib/temporalio/api/enums/v1/activity.rb +1 -1
  12. data/lib/temporalio/api/enums/v1/batch_operation.rb +1 -1
  13. data/lib/temporalio/api/enums/v1/common.rb +2 -1
  14. data/lib/temporalio/api/enums/v1/failed_cause.rb +1 -1
  15. data/lib/temporalio/api/enums/v1/time_skipping.rb +21 -0
  16. data/lib/temporalio/api/errordetails/v1/message.rb +2 -1
  17. data/lib/temporalio/api/history/v1/message.rb +1 -1
  18. data/lib/temporalio/api/namespace/v1/message.rb +1 -1
  19. data/lib/temporalio/api/taskqueue/v1/message.rb +2 -1
  20. data/lib/temporalio/api/worker/v1/message.rb +13 -1
  21. data/lib/temporalio/api/workflow/v1/message.rb +1 -1
  22. data/lib/temporalio/api/workflowservice/v1/request_response.rb +4 -1
  23. data/lib/temporalio/api/workflowservice/v1/service.rb +1 -1
  24. data/lib/temporalio/client/activity_execution.rb +82 -1
  25. data/lib/temporalio/client/activity_execution_options.rb +39 -0
  26. data/lib/temporalio/client/activity_execution_status.rb +1 -0
  27. data/lib/temporalio/client/activity_handle.rb +122 -1
  28. data/lib/temporalio/client/activity_options.rb +113 -0
  29. data/lib/temporalio/client/connection/workflow_service.rb +15 -0
  30. data/lib/temporalio/client/connection.rb +33 -3
  31. data/lib/temporalio/client/interceptor.rb +65 -0
  32. data/lib/temporalio/client/schedule.rb +4 -5
  33. data/lib/temporalio/client/workflow_execution.rb +2 -2
  34. data/lib/temporalio/client/workflow_handle.rb +2 -1
  35. data/lib/temporalio/client.rb +4 -6
  36. data/lib/temporalio/converters/data_converter.rb +1 -0
  37. data/lib/temporalio/converters/failure_converter.rb +7 -4
  38. data/lib/temporalio/internal/bridge/api/common/common.rb +2 -1
  39. data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +1 -1
  40. data/lib/temporalio/internal/bridge/client.rb +3 -1
  41. data/lib/temporalio/internal/bridge/runtime.rb +4 -1
  42. data/lib/temporalio/internal/bridge/worker.rb +3 -1
  43. data/lib/temporalio/internal/client/implementation.rb +54 -2
  44. data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +9 -0
  45. data/lib/temporalio/runtime.rb +25 -7
  46. data/lib/temporalio/scoped_logger.rb +18 -0
  47. data/lib/temporalio/version.rb +1 -1
  48. data/lib/temporalio/worker/activity_executor/fiber.rb +11 -1
  49. data/lib/temporalio/worker/workflow_replayer.rb +2 -0
  50. data/lib/temporalio/worker.rb +24 -4
  51. data/lib/temporalio/workflow.rb +8 -9
  52. data/rbi/temporalio/api/activity/v1/message.rbi +100 -14
  53. data/rbi/temporalio/api/batch/v1/message.rbi +229 -2
  54. data/rbi/temporalio/api/command/v1/message.rbi +22 -2
  55. data/rbi/temporalio/api/common/v1/message.rbi +548 -74
  56. data/rbi/temporalio/api/enums/v1/activity.rbi +1 -0
  57. data/rbi/temporalio/api/enums/v1/batch_operation.rbi +9 -0
  58. data/rbi/temporalio/api/enums/v1/common.rbi +18 -0
  59. data/rbi/temporalio/api/enums/v1/failed_cause.rbi +4 -0
  60. data/rbi/temporalio/api/enums/v1/time_skipping.rbi +22 -0
  61. data/rbi/temporalio/api/errordetails/v1/message.rbi +59 -2
  62. data/rbi/temporalio/api/history/v1/message.rbi +27 -7
  63. data/rbi/temporalio/api/namespace/v1/message.rbi +95 -4
  64. data/rbi/temporalio/api/taskqueue/v1/message.rbi +113 -2
  65. data/rbi/temporalio/api/worker/v1/message.rbi +742 -2
  66. data/rbi/temporalio/api/workflow/v1/message.rbi +22 -2
  67. data/rbi/temporalio/api/workflowservice/v1/request_response.rbi +701 -117
  68. data/rbi/temporalio/api/workflowservice/v1/service_services.rbi +8 -0
  69. data/rbi/temporalio/client/activity_execution.rbi +27 -0
  70. data/rbi/temporalio/client/activity_execution_options.rbi +58 -0
  71. data/rbi/temporalio/client/activity_execution_status.rbi +1 -0
  72. data/rbi/temporalio/client/activity_handle.rbi +43 -2
  73. data/rbi/temporalio/client/activity_options.rbi +49 -0
  74. data/rbi/temporalio/client/connection/workflow_service.rbi +3 -0
  75. data/rbi/temporalio/client/connection.rbi +2 -0
  76. data/rbi/temporalio/client/interceptor.rbi +107 -0
  77. data/rbi/temporalio/converters/failure_converter.rbi +7 -2
  78. data/rbi/temporalio/internal/bridge/api/common/common.rbi +115 -0
  79. data/rbi/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rbi +42 -2
  80. data/rbi/temporalio/internal/bridge/runtime.rbi +24 -4
  81. data/rbi/temporalio/internal/bridge/worker.rbi +2 -0
  82. data/rbi/temporalio/runtime.rbi +13 -4
  83. data/rbi/temporalio/scoped_logger.rbi +1 -1
  84. data/rbi/temporalio/worker.rbi +9 -2
  85. data/rbi/temporalio/workflow/future.rbi +1 -1
  86. data/sig/temporalio/api/activity/v1/message.rbs +48 -2
  87. data/sig/temporalio/api/batch/v1/message.rbs +86 -0
  88. data/sig/temporalio/api/command/v1/message.rbs +10 -0
  89. data/sig/temporalio/api/common/v1/message.rbs +240 -39
  90. data/sig/temporalio/api/enums/v1/activity.rbs +9 -5
  91. data/sig/temporalio/api/enums/v1/batch_operation.rbs +33 -3
  92. data/sig/temporalio/api/enums/v1/common.rbs +23 -0
  93. data/sig/temporalio/api/enums/v1/failed_cause.rbs +18 -6
  94. data/sig/temporalio/api/enums/v1/time_skipping.rbs +58 -0
  95. data/sig/temporalio/api/errordetails/v1/message.rbs +19 -0
  96. data/sig/temporalio/api/history/v1/message.rbs +13 -3
  97. data/sig/temporalio/api/namespace/v1/message.rbs +43 -0
  98. data/sig/temporalio/api/taskqueue/v1/message.rbs +44 -0
  99. data/sig/temporalio/api/worker/v1/message.rbs +410 -0
  100. data/sig/temporalio/api/workflow/v1/message.rbs +10 -0
  101. data/sig/temporalio/api/workflowservice/v1/request_response.rbs +311 -40
  102. data/sig/temporalio/client/activity_execution.rbs +10 -0
  103. data/sig/temporalio/client/activity_execution_options.rbs +27 -0
  104. data/sig/temporalio/client/activity_execution_status.rbs +1 -0
  105. data/sig/temporalio/client/activity_handle.rbs +23 -1
  106. data/sig/temporalio/client/activity_options.rbs +30 -0
  107. data/sig/temporalio/client/connection/workflow_service.rbs +4 -0
  108. data/sig/temporalio/client/connection.rbs +14 -1
  109. data/sig/temporalio/client/interceptor.rbs +62 -0
  110. data/sig/temporalio/converters/failure_converter.rbs +4 -1
  111. data/sig/temporalio/internal/bridge/api/common/common.rbs +50 -0
  112. data/sig/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rbs +20 -0
  113. data/sig/temporalio/internal/bridge/client.rbs +5 -1
  114. data/sig/temporalio/internal/bridge/runtime.rbs +9 -3
  115. data/sig/temporalio/internal/bridge/worker.rbs +5 -1
  116. data/sig/temporalio/internal/client/implementation.rbs +7 -0
  117. data/sig/temporalio/runtime.rbs +14 -3
  118. data/sig/temporalio/scoped_logger.rbs +1 -1
  119. data/sig/temporalio/worker.rbs +8 -2
  120. metadata +10 -1
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'temporalio/api'
4
+ require 'temporalio/internal/proto_utils'
5
+
6
+ module Temporalio
7
+ class Client
8
+ # The activity options that {ActivityHandle#update_options} can change.
9
+ #
10
+ # Updates are created from the keys below, via {Key#value_set} to set an option or
11
+ # {Key#value_unset} to clear it. An option with no update is left untouched.
12
+ #
13
+ # WARNING: Standalone Activities are experimental.
14
+ module ActivityOptions
15
+ # Typed key for one updatable activity option. Use the keys on {ActivityOptions} rather than
16
+ # constructing these directly.
17
+ class Key
18
+ # @return [String] Field-mask path this key updates.
19
+ attr_reader :name
20
+
21
+ # @!visibility private
22
+ def initialize(name, &to_proto)
23
+ @name = name
24
+ @to_proto = to_proto
25
+ freeze
26
+ end
27
+
28
+ # Create an update that sets this option to the given value.
29
+ #
30
+ # @param value [Object] Value to set. Cannot be nil.
31
+ # @return [Update] Created update.
32
+ def value_set(value)
33
+ raise ArgumentError, 'Value cannot be nil, use value_unset' if value.nil?
34
+
35
+ Update.new(self, value)
36
+ end
37
+
38
+ # Create an update that clears this option server-side.
39
+ #
40
+ # @return [Update] Created update.
41
+ def value_unset
42
+ Update.new(self, nil)
43
+ end
44
+
45
+ # @!visibility private
46
+ def _apply(proto, value)
47
+ @to_proto.call(proto, value)
48
+ end
49
+ end
50
+
51
+ # A single change to an activity's options that can be separately applied.
52
+ class Update
53
+ # @return [Key] Key this update applies to.
54
+ attr_reader :key
55
+
56
+ # @return [Object, nil] Value to set, or `nil` to clear the option.
57
+ attr_reader :value
58
+
59
+ # Create an update. Users may find it easier to use {Key#value_set} and {Key#value_unset}.
60
+ #
61
+ # @param key [Key] Key to update.
62
+ # @param value [Object, nil] Value to set, or nil to clear the option.
63
+ def initialize(key, value)
64
+ raise ArgumentError, 'Key must be a key' unless key.is_a?(Key)
65
+
66
+ @key = key
67
+ @value = value
68
+ freeze
69
+ end
70
+ end
71
+
72
+ # @return [Key] New task queue.
73
+ TASK_QUEUE = Key.new('task_queue.name') do |proto, value|
74
+ proto.task_queue = Api::TaskQueue::V1::TaskQueue.new(name: value.to_s)
75
+ end
76
+
77
+ # @return [Key] New schedule-to-close timeout in seconds.
78
+ SCHEDULE_TO_CLOSE_TIMEOUT = Key.new('schedule_to_close_timeout') do |proto, value|
79
+ proto.schedule_to_close_timeout = Internal::ProtoUtils.seconds_to_duration(value)
80
+ end
81
+
82
+ # @return [Key] New schedule-to-start timeout in seconds.
83
+ SCHEDULE_TO_START_TIMEOUT = Key.new('schedule_to_start_timeout') do |proto, value|
84
+ proto.schedule_to_start_timeout = Internal::ProtoUtils.seconds_to_duration(value)
85
+ end
86
+
87
+ # @return [Key] New start-to-close timeout in seconds.
88
+ START_TO_CLOSE_TIMEOUT = Key.new('start_to_close_timeout') do |proto, value|
89
+ proto.start_to_close_timeout = Internal::ProtoUtils.seconds_to_duration(value)
90
+ end
91
+
92
+ # @return [Key] New heartbeat timeout in seconds.
93
+ HEARTBEAT_TIMEOUT = Key.new('heartbeat_timeout') do |proto, value|
94
+ proto.heartbeat_timeout = Internal::ProtoUtils.seconds_to_duration(value)
95
+ end
96
+
97
+ # @return [Key] New start delay in seconds.
98
+ START_DELAY = Key.new('start_delay') do |proto, value|
99
+ proto.start_delay = Internal::ProtoUtils.seconds_to_duration(value)
100
+ end
101
+
102
+ # @return [Key] New retry policy.
103
+ RETRY_POLICY = Key.new('retry_policy') do |proto, value|
104
+ proto.retry_policy = value._to_proto
105
+ end
106
+
107
+ # @return [Key] New priority.
108
+ PRIORITY = Key.new('priority') do |proto, value|
109
+ proto.priority = value._to_proto
110
+ end
111
+ end
112
+ end
113
+ end
@@ -1845,6 +1845,21 @@ module Temporalio
1845
1845
  rpc_options:
1846
1846
  )
1847
1847
  end
1848
+
1849
+ # Calls WorkflowService.PollWorkflowExecutionTimeSkipping API call.
1850
+ #
1851
+ # @param request [Temporalio::Api::WorkflowService::V1::PollWorkflowExecutionTimeSkippingRequest] API request.
1852
+ # @param rpc_options [RPCOptions, nil] Advanced RPC options.
1853
+ # @return [Temporalio::Api::WorkflowService::V1::PollWorkflowExecutionTimeSkippingResponse] API response.
1854
+ def poll_workflow_execution_time_skipping(request, rpc_options: nil)
1855
+ invoke_rpc(
1856
+ rpc: 'poll_workflow_execution_time_skipping',
1857
+ request_class: Temporalio::Api::WorkflowService::V1::PollWorkflowExecutionTimeSkippingRequest,
1858
+ response_class: Temporalio::Api::WorkflowService::V1::PollWorkflowExecutionTimeSkippingResponse,
1859
+ request:,
1860
+ rpc_options:
1861
+ )
1862
+ end
1848
1863
  end
1849
1864
  end
1850
1865
  end
@@ -26,7 +26,8 @@ module Temporalio
26
26
  :runtime,
27
27
  :lazy_connect,
28
28
  :dns_load_balancing,
29
- :grpc_compression
29
+ :grpc_compression,
30
+ :payload_limits
30
31
  )
31
32
 
32
33
  # Options as returned from {options} for +**to_h+ splat use in {initialize}. See {initialize} for details.
@@ -169,6 +170,28 @@ module Temporalio
169
170
  end
170
171
  end
171
172
 
173
+ PayloadLimitsOptions = Data.define(
174
+ :payloads_warn_size,
175
+ :memo_warn_size
176
+ )
177
+
178
+ # Payload size-limit options for client connections.
179
+ #
180
+ # @note WARNING: Payload size-limit enforcement is experimental and the API may change in the future.
181
+ #
182
+ # @!attribute payloads_warn_size
183
+ # @return [Integer] Warning threshold, in bytes, for the size of an outbound payload-bearing field.
184
+ # Over-threshold fields are logged but still sent to the server. Defaults to 512 KiB; +0+ disables the
185
+ # warning.
186
+ # @!attribute memo_warn_size
187
+ # @return [Integer] Warning threshold, in bytes, for outbound memo size. Over-threshold memos are logged
188
+ # but still sent to the server. Defaults to 2 KiB; +0+ disables the warning.
189
+ class PayloadLimitsOptions
190
+ def initialize(payloads_warn_size: 512 * 1024, memo_warn_size: 2 * 1024)
191
+ super
192
+ end
193
+ end
194
+
172
195
  # @return [Options] Frozen options for this client which has the same attributes as {initialize}. Note that if
173
196
  # {api_key=} or {rpc_metadata=} are updated, the options object is replaced with those changes (it is not
174
197
  # mutated in place).
@@ -210,6 +233,9 @@ module Temporalio
210
233
  # is +nil+ (disabled). Silently disabled when +http_connect_proxy+ is set, since the two are mutually exclusive.
211
234
  # @param grpc_compression [GrpcCompressionOptions::Gzip, GrpcCompressionOptions::None] Transport-level gRPC
212
235
  # compression. Defaults to gzip. Set to {GrpcCompressionOptions::None} to opt out.
236
+ # @param payload_limits [PayloadLimitsOptions] Payload size-limit options for this connection. Defaults to a
237
+ # {PayloadLimitsOptions} with the standard warning thresholds; see that type for the defaults and how to disable
238
+ # a warning. WARNING: This is experimental and may change in the future.
213
239
  # @param around_connect [Proc, nil] If present, this proc accepts two values: options and a block. The block must
214
240
  # be yielded to only once with the options. The block does not return a meaningful value, nor should
215
241
  # around_connect.
@@ -228,6 +254,7 @@ module Temporalio
228
254
  lazy_connect: false,
229
255
  dns_load_balancing: nil,
230
256
  grpc_compression: GrpcCompressionOptions::Gzip.new,
257
+ payload_limits: PayloadLimitsOptions.new,
231
258
  around_connect: nil
232
259
  )
233
260
  @options = Options.new(
@@ -242,7 +269,8 @@ module Temporalio
242
269
  runtime:,
243
270
  lazy_connect:,
244
271
  dns_load_balancing:,
245
- grpc_compression:
272
+ grpc_compression:,
273
+ payload_limits:
246
274
  ).freeze
247
275
  @core_client_mutex = Mutex.new
248
276
  # Create core client now if not lazy, applying around_connect if present
@@ -344,7 +372,9 @@ module Temporalio
344
372
  max_elapsed_time: @options.rpc_retry.max_elapsed_time,
345
373
  max_retries: @options.rpc_retry.max_retries
346
374
  ),
347
- identity: @options.identity || "#{Process.pid}@#{Socket.gethostname}"
375
+ identity: @options.identity || "#{Process.pid}@#{Socket.gethostname}",
376
+ payloads_warn_size: @options.payload_limits.payloads_warn_size,
377
+ memo_warn_size: @options.payload_limits.memo_warn_size
348
378
  )
349
379
  grpc_compression_codec = case @options.grpc_compression
350
380
  when GrpcCompressionOptions::Gzip
@@ -291,6 +291,10 @@ module Temporalio
291
291
  DescribeActivityInput = Data.define(
292
292
  :activity_id,
293
293
  :activity_run_id,
294
+ :include_input,
295
+ :include_outcome,
296
+ :include_heartbeat_details,
297
+ :include_last_failure,
294
298
  :rpc_options
295
299
  )
296
300
 
@@ -314,6 +318,39 @@ module Temporalio
314
318
  :rpc_options
315
319
  )
316
320
 
321
+ # Input for {Outbound.pause_activity}.
322
+ #
323
+ # WARNING: Standalone Activities are experimental.
324
+ PauseActivityInput = Data.define(
325
+ :activity_id,
326
+ :activity_run_id,
327
+ :reason,
328
+ :rpc_options
329
+ )
330
+
331
+ # Input for {Outbound.unpause_activity}.
332
+ #
333
+ # WARNING: Standalone Activities are experimental.
334
+ UnpauseActivityInput = Data.define(
335
+ :activity_id,
336
+ :activity_run_id,
337
+ :reason,
338
+ :jitter,
339
+ :rpc_options
340
+ )
341
+
342
+ # Input for {Outbound.update_activity_options}.
343
+ #
344
+ # WARNING: Standalone Activities are experimental.
345
+ UpdateActivityOptionsInput = Data.define(
346
+ :activity_id,
347
+ :activity_run_id,
348
+ :activity_options,
349
+ :update_mask,
350
+ :restore_original,
351
+ :rpc_options
352
+ )
353
+
317
354
  # Input for {Outbound.list_activities}.
318
355
  #
319
356
  # WARNING: Standalone Activities are experimental.
@@ -587,6 +624,34 @@ module Temporalio
587
624
  next_interceptor.terminate_activity(input)
588
625
  end
589
626
 
627
+ # Called for every {ActivityHandle.pause} call.
628
+ #
629
+ # WARNING: Standalone Activities are experimental.
630
+ #
631
+ # @param input [PauseActivityInput] Input.
632
+ def pause_activity(input)
633
+ next_interceptor.pause_activity(input)
634
+ end
635
+
636
+ # Called for every {ActivityHandle.unpause} call.
637
+ #
638
+ # WARNING: Standalone Activities are experimental.
639
+ #
640
+ # @param input [UnpauseActivityInput] Input.
641
+ def unpause_activity(input)
642
+ next_interceptor.unpause_activity(input)
643
+ end
644
+
645
+ # Called for every {ActivityHandle.update_options} call.
646
+ #
647
+ # WARNING: Standalone Activities are experimental.
648
+ #
649
+ # @param input [UpdateActivityOptionsInput] Input.
650
+ # @return [Api::Activity::V1::ActivityOptions] Activity options after the update.
651
+ def update_activity_options(input)
652
+ next_interceptor.update_activity_options(input)
653
+ end
654
+
590
655
  # Called for every {Client.list_activities} call.
591
656
  #
592
657
  # WARNING: Standalone Activities are experimental.
@@ -193,12 +193,11 @@ module Temporalio
193
193
  # @return [String] Task queue to run the workflow on.
194
194
  # @!attribute static_summary
195
195
  # @return [String, nil] Fixed single-line summary for this workflow execution that may appear in CLI/UI.
196
- # This can be in single-line Temporal markdown format. This is currently experimental.
196
+ # This can be in single-line Temporal markdown format.
197
197
  # @!attribute static_details
198
198
  # @return [String, nil] Fixed details for this workflow execution that may appear in CLI/UI. This can be in
199
199
  # Temporal markdown format and can be multiple lines. This is a fixed value on the workflow that cannot be
200
- # updated. For details that can be updated, use {Workflow.current_details=} within the workflow. This is
201
- # currently experimental.
200
+ # updated. For details that can be updated, use {Workflow.current_details=} within the workflow.
202
201
  # @!attribute execution_timeout
203
202
  # @return [Float, nil] Total workflow execution timeout in seconds including retries and continue as new.
204
203
  # @!attribute run_timeout
@@ -231,11 +230,11 @@ module Temporalio
231
230
  # @param id [String] Unique identifier for the workflow execution.
232
231
  # @param task_queue [String] Task queue to run the workflow on.
233
232
  # @param static_summary [String, nil] Fixed single-line summary for this workflow execution that may appear
234
- # in CLI/UI. This can be in single-line Temporal markdown format. This is currently experimental.
233
+ # in CLI/UI. This can be in single-line Temporal markdown format.
235
234
  # @param static_details [String, nil] Fixed details for this workflow execution that may appear in CLI/UI.
236
235
  # This can be in Temporal markdown format and can be multiple lines. This is a fixed value on the workflow
237
236
  # that cannot be updated. For details that can be updated, use {Workflow.current_details=} within the
238
- # workflow. This is currently experimental.
237
+ # workflow.
239
238
  # @param execution_timeout [Float, nil] Total workflow execution timeout in seconds including retries and
240
239
  # continue as new.
241
240
  # @param run_timeout [Float, nil] Timeout of a single workflow run in seconds.
@@ -96,12 +96,12 @@ module Temporalio
96
96
  @data_converter = data_converter
97
97
  end
98
98
 
99
- # @return [String, nil] Static summary configured on the workflow. This is currently experimental.
99
+ # @return [String, nil] Static summary configured on the workflow.
100
100
  def static_summary
101
101
  user_metadata.first
102
102
  end
103
103
 
104
- # @return [String, nil] Static details configured on the workflow. This is currently experimental.
104
+ # @return [String, nil] Static details configured on the workflow.
105
105
  def static_details
106
106
  user_metadata.last
107
107
  end
@@ -92,7 +92,8 @@ module Temporalio
92
92
  skip_archival: true,
93
93
  specific_run_id: hist_run_id,
94
94
  rpc_options:
95
- ).next
95
+ ).find { true }
96
+ next unless event
96
97
 
97
98
  # Check each close type'
98
99
  case event.event_type
@@ -287,11 +287,10 @@ module Temporalio
287
287
  # @param id [String] Unique identifier for the workflow execution.
288
288
  # @param task_queue [String] Task queue to run the workflow on.
289
289
  # @param static_summary [String, nil] Fixed single-line summary for this workflow execution that may appear in
290
- # CLI/UI. This can be in single-line Temporal markdown format. This is currently experimental.
290
+ # CLI/UI. This can be in single-line Temporal markdown format.
291
291
  # @param static_details [String, nil] Fixed details for this workflow execution that may appear in CLI/UI. This can
292
292
  # be in Temporal markdown format and can be multiple lines. This is a fixed value on the workflow that cannot be
293
- # updated. For details that can be updated, use {Workflow.current_details=} within the workflow. This is currently
294
- # experimental.
293
+ # updated. For details that can be updated, use {Workflow.current_details=} within the workflow.
295
294
  # @param execution_timeout [Float, nil] Total workflow execution timeout in seconds including retries and continue
296
295
  # as new.
297
296
  # @param run_timeout [Float, nil] Timeout of a single workflow run in seconds.
@@ -380,11 +379,10 @@ module Temporalio
380
379
  # @param id [String] Unique identifier for the workflow execution.
381
380
  # @param task_queue [String] Task queue to run the workflow on.
382
381
  # @param static_summary [String, nil] Fixed single-line summary for this workflow execution that may appear in
383
- # CLI/UI. This can be in single-line Temporal markdown format. This is currently experimental.
382
+ # CLI/UI. This can be in single-line Temporal markdown format.
384
383
  # @param static_details [String, nil] Fixed details for this workflow execution that may appear in CLI/UI. This can
385
384
  # be in Temporal markdown format and can be multiple lines. This is a fixed value on the workflow that cannot be
386
- # updated. For details that can be updated, use {Workflow.current_details=} within the workflow. This is currently
387
- # experimental.
385
+ # updated. For details that can be updated, use {Workflow.current_details=} within the workflow.
388
386
  # @param execution_timeout [Float, nil] Total workflow execution timeout in seconds including retries and continue
389
387
  # as new.
390
388
  # @param run_timeout [Float, nil] Timeout of a single workflow run in seconds.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'temporalio/api'
4
4
  require 'temporalio/converters/failure_converter'
5
+ require 'temporalio/converters/payload_codec'
5
6
  require 'temporalio/converters/payload_converter'
6
7
 
7
8
  module Temporalio
@@ -21,8 +21,11 @@ module Temporalio
21
21
  #
22
22
  # @param encode_common_attributes [Boolean] If +true+, the message and stack trace of the failure will be moved
23
23
  # into the encoded attribute section of the failure which can be encoded with a codec.
24
- def initialize(encode_common_attributes: false)
24
+ # @param process_common_attributes [Proc, nil] If present, called with the message and stack trace of failure
25
+ # before they are converted to a payload.
26
+ def initialize(encode_common_attributes: false, process_common_attributes: nil)
25
27
  @encode_common_attributes = encode_common_attributes
28
+ @process_common_attributes = process_common_attributes
26
29
  end
27
30
 
28
31
  # Convert a Ruby error to a Temporal failure.
@@ -104,9 +107,9 @@ module Temporalio
104
107
 
105
108
  # If encoding common attributes, move message and stack trace
106
109
  if @encode_common_attributes
107
- failure.encoded_attributes = converter.to_payload(
108
- { message: failure.message, stack_trace: failure.stack_trace }
109
- )
110
+ common_attributes = { message: failure.message, stack_trace: failure.stack_trace }
111
+ common_attributes = @process_common_attributes.call(common_attributes) if @process_common_attributes
112
+ failure.encoded_attributes = converter.to_payload(common_attributes)
110
113
  failure.message = 'Encoded failure'
111
114
  failure.stack_trace = ''
112
115
  end
@@ -7,7 +7,7 @@ require 'google/protobuf'
7
7
  require 'google/protobuf/duration_pb'
8
8
 
9
9
 
10
- descriptor_data = "\n%temporal/sdk/core/common/common.proto\x12\x0e\x63oresdk.common\x1a\x1egoogle/protobuf/duration.proto\"U\n\x1bNamespacedWorkflowExecution\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\"D\n\x17WorkerDeploymentVersion\x12\x17\n\x0f\x64\x65ployment_name\x18\x01 \x01(\t\x12\x10\n\x08\x62uild_id\x18\x02 \x01(\t*@\n\x10VersioningIntent\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCOMPATIBLE\x10\x01\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10\x02\x42,\xea\x02)Temporalio::Internal::Bridge::Api::Commonb\x06proto3"
10
+ descriptor_data = "\n%temporal/sdk/core/common/common.proto\x12\x0e\x63oresdk.common\x1a\x1egoogle/protobuf/duration.proto\"U\n\x1bNamespacedWorkflowExecution\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\"D\n\x17WorkerDeploymentVersion\x12\x17\n\x0f\x64\x65ployment_name\x18\x01 \x01(\t\x12\x10\n\x08\x62uild_id\x18\x02 \x01(\t\"\x92\x01\n\x16\x45xternalStorageMetrics\x12\x15\n\rpayload_count\x18\x01 \x01(\x04\x12\x18\n\x10total_size_bytes\x18\x02 \x01(\x04\x12\x31\n\x0etotal_duration\x18\x03 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x14\n\x0c\x64river_names\x18\x04 \x03(\t*@\n\x10VersioningIntent\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCOMPATIBLE\x10\x01\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10\x02\x42,\xea\x02)Temporalio::Internal::Bridge::Api::Commonb\x06proto3"
11
11
 
12
12
  pool = ::Google::Protobuf::DescriptorPool.generated_pool
13
13
  pool.add_serialized_file(descriptor_data)
@@ -19,6 +19,7 @@ module Temporalio
19
19
  module Common
20
20
  NamespacedWorkflowExecution = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.NamespacedWorkflowExecution").msgclass
21
21
  WorkerDeploymentVersion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.WorkerDeploymentVersion").msgclass
22
+ ExternalStorageMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.ExternalStorageMetrics").msgclass
22
23
  VersioningIntent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.VersioningIntent").enummodule
23
24
  end
24
25
  end
@@ -11,7 +11,7 @@ require 'temporalio/internal/bridge/api/common/common'
11
11
  require 'temporalio/internal/bridge/api/workflow_commands/workflow_commands'
12
12
 
13
13
 
14
- descriptor_data = "\n?temporal/sdk/core/workflow_completion/workflow_completion.proto\x12\x1b\x63oresdk.workflow_completion\x1a%temporal/api/failure/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a;temporal/sdk/core/workflow_commands/workflow_commands.proto\"\xac\x01\n\x1cWorkflowActivationCompletion\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12:\n\nsuccessful\x18\x02 \x01(\x0b\x32$.coresdk.workflow_completion.SuccessH\x00\x12\x36\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32$.coresdk.workflow_completion.FailureH\x00\x42\x08\n\x06status\"\xac\x01\n\x07Success\x12<\n\x08\x63ommands\x18\x01 \x03(\x0b\x32*.coresdk.workflow_commands.WorkflowCommand\x12\x1b\n\x13used_internal_flags\x18\x06 \x03(\r\x12\x46\n\x13versioning_behavior\x18\x07 \x01(\x0e\x32).temporal.api.enums.v1.VersioningBehavior\"\x81\x01\n\x07\x46\x61ilure\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12\x43\n\x0b\x66orce_cause\x18\x02 \x01(\x0e\x32..temporal.api.enums.v1.WorkflowTaskFailedCauseB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowCompletionb\x06proto3"
14
+ descriptor_data = "\n?temporal/sdk/core/workflow_completion/workflow_completion.proto\x12\x1b\x63oresdk.workflow_completion\x1a%temporal/api/failure/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a;temporal/sdk/core/workflow_commands/workflow_commands.proto\"\xbe\x02\n\x1cWorkflowActivationCompletion\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12:\n\nsuccessful\x18\x02 \x01(\x0b\x32$.coresdk.workflow_completion.SuccessH\x00\x12\x36\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32$.coresdk.workflow_completion.FailureH\x00\x12H\n\x18payload_download_metrics\x18\x04 \x01(\x0b\x32&.coresdk.common.ExternalStorageMetrics\x12\x46\n\x16payload_upload_metrics\x18\x05 \x01(\x0b\x32&.coresdk.common.ExternalStorageMetricsB\x08\n\x06status\"\xac\x01\n\x07Success\x12<\n\x08\x63ommands\x18\x01 \x03(\x0b\x32*.coresdk.workflow_commands.WorkflowCommand\x12\x1b\n\x13used_internal_flags\x18\x06 \x03(\r\x12\x46\n\x13versioning_behavior\x18\x07 \x01(\x0e\x32).temporal.api.enums.v1.VersioningBehavior\"\x81\x01\n\x07\x46\x61ilure\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12\x43\n\x0b\x66orce_cause\x18\x02 \x01(\x0e\x32..temporal.api.enums.v1.WorkflowTaskFailedCauseB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowCompletionb\x06proto3"
15
15
 
16
16
  pool = ::Google::Protobuf::DescriptorPool.generated_pool
17
17
  pool.add_serialized_file(descriptor_data)
@@ -18,7 +18,9 @@ module Temporalio
18
18
  :keep_alive, # Optional
19
19
  :http_connect_proxy, # Optional
20
20
  :dns_load_balancing, # Optional
21
- :grpc_compression
21
+ :grpc_compression,
22
+ :payloads_warn_size,
23
+ :memo_warn_size
22
24
  )
23
25
 
24
26
  TLSOptions = Struct.new(
@@ -6,7 +6,9 @@ module Temporalio
6
6
  class Runtime
7
7
  Options = Struct.new(
8
8
  :telemetry,
9
- :worker_heartbeat_interval
9
+ :worker_heartbeat_interval,
10
+ :disable_environment_info,
11
+ :runtime_version
10
12
  )
11
13
 
12
14
  TelemetryOptions = Struct.new(
@@ -16,6 +18,7 @@ module Temporalio
16
18
 
17
19
  LoggingOptions = Struct.new(
18
20
  :log_filter,
21
+ :log_format,
19
22
  :forward_to # Optional
20
23
  )
21
24
 
@@ -24,11 +24,13 @@ module Temporalio
24
24
  :default_heartbeat_throttle_interval,
25
25
  :max_worker_activities_per_second,
26
26
  :max_task_queue_activities_per_second,
27
+ :max_eager_activity_reservations_per_workflow_task,
27
28
  :graceful_shutdown_period,
28
29
  :nondeterminism_as_workflow_fail,
29
30
  :nondeterminism_as_workflow_fail_for_types,
30
31
  :deployment_options,
31
- :plugins
32
+ :plugins,
33
+ :disable_payload_error_limit
32
34
  )
33
35
 
34
36
  TunerOptions = Struct.new(
@@ -29,7 +29,7 @@ require 'temporalio/workflow/definition'
29
29
  module Temporalio
30
30
  module Internal
31
31
  module Client
32
- class Implementation < Temporalio::Client::Interceptor::Outbound
32
+ class Implementation < Temporalio::Client::Interceptor::Outbound # rubocop:disable Metrics/ClassLength
33
33
  # Proto routing convention for standalone activity completion: `*_by_id` requests carry
34
34
  # `resource_id = "activity:<activity_id>"`. See the resource_id field comment on
35
35
  # `RecordActivityTaskHeartbeatByIdRequest` (and the analogous Completed/Failed/Canceled
@@ -1025,7 +1025,11 @@ module Temporalio
1025
1025
  Api::WorkflowService::V1::DescribeActivityExecutionRequest.new(
1026
1026
  namespace: @client.namespace,
1027
1027
  activity_id: input.activity_id,
1028
- run_id: input.activity_run_id || ''
1028
+ run_id: input.activity_run_id || '',
1029
+ include_input: input.include_input,
1030
+ include_outcome: input.include_outcome,
1031
+ include_heartbeat_details: input.include_heartbeat_details,
1032
+ include_last_failure: input.include_last_failure
1029
1033
  ),
1030
1034
  rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
1031
1035
  )
@@ -1062,6 +1066,54 @@ module Temporalio
1062
1066
  nil
1063
1067
  end
1064
1068
 
1069
+ def pause_activity(input)
1070
+ @client.workflow_service.pause_activity_execution(
1071
+ Api::WorkflowService::V1::PauseActivityExecutionRequest.new(
1072
+ namespace: @client.namespace,
1073
+ activity_id: input.activity_id,
1074
+ run_id: input.activity_run_id || '',
1075
+ identity: @client.connection.identity,
1076
+ request_id: SecureRandom.uuid,
1077
+ reason: input.reason || ''
1078
+ ),
1079
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
1080
+ )
1081
+ nil
1082
+ end
1083
+
1084
+ def unpause_activity(input)
1085
+ @client.workflow_service.unpause_activity_execution(
1086
+ Api::WorkflowService::V1::UnpauseActivityExecutionRequest.new(
1087
+ namespace: @client.namespace,
1088
+ activity_id: input.activity_id,
1089
+ run_id: input.activity_run_id || '',
1090
+ identity: @client.connection.identity,
1091
+ request_id: SecureRandom.uuid,
1092
+ reason: input.reason || '',
1093
+ jitter: ProtoUtils.seconds_to_duration(input.jitter)
1094
+ ),
1095
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
1096
+ )
1097
+ nil
1098
+ end
1099
+
1100
+ def update_activity_options(input)
1101
+ resp = @client.workflow_service.update_activity_execution_options(
1102
+ Api::WorkflowService::V1::UpdateActivityExecutionOptionsRequest.new(
1103
+ namespace: @client.namespace,
1104
+ activity_id: input.activity_id,
1105
+ run_id: input.activity_run_id || '',
1106
+ identity: @client.connection.identity,
1107
+ request_id: SecureRandom.uuid,
1108
+ activity_options: input.activity_options,
1109
+ update_mask: input.update_mask,
1110
+ restore_original: input.restore_original
1111
+ ),
1112
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
1113
+ )
1114
+ Temporalio::Client::ActivityExecutionOptions._from_proto(resp.activity_options)
1115
+ end
1116
+
1065
1117
  def list_activities(input)
1066
1118
  Enumerator.new do |yielder|
1067
1119
  req = Api::WorkflowService::V1::ListActivityExecutionsRequest.new(
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'temporalio/internal/workflow_task_failure_error'
3
4
  require 'temporalio/worker/illegal_workflow_call_validator'
4
5
  require 'temporalio/workflow'
5
6
 
@@ -92,6 +93,11 @@ module Temporalio
92
93
  ))
93
94
  nil
94
95
  rescue Exception => e # rubocop:disable Lint/RescueException
96
+ # Errors that invalidate the whole workflow task (e.g. an async DeadlockError landing while the
97
+ # validator runs) must propagate with their class intact so they fail the task instead of being
98
+ # flattened into a NondeterminismError message that futures may store
99
+ raise if e.is_a?(Internal::WorkflowTaskFailureError)
100
+
95
101
  ", reason: #{e}"
96
102
  end
97
103
  else
@@ -108,6 +114,9 @@ module Temporalio
108
114
  ))
109
115
  nil
110
116
  rescue Exception => e # rubocop:disable Lint/RescueException
117
+ # See workflow-task-failure comment on the class-level validator rescue above
118
+ raise if e.is_a?(Internal::WorkflowTaskFailureError)
119
+
111
120
  ", reason: #{e}"
112
121
  end
113
122
  end