temporalio 1.8.0 → 1.10.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.
- checksums.yaml +4 -4
- data/Cargo.lock +268 -73
- data/README.md +3 -3
- data/Rakefile +28 -0
- data/ext/Cargo.toml +3 -3
- data/lib/temporalio/activity/info.rb +0 -3
- data/lib/temporalio/api/activity/v1/message.rb +2 -1
- data/lib/temporalio/api/callback/v1/message.rb +1 -1
- data/lib/temporalio/api/common/v1/message.rb +3 -1
- data/lib/temporalio/api/compute/v1/config.rb +1 -1
- data/lib/temporalio/api/enums/v1/common.rb +1 -1
- data/lib/temporalio/api/enums/v1/failed_cause.rb +2 -1
- data/lib/temporalio/api/export/v1/message.rb +4 -1
- data/lib/temporalio/api/history/v1/message.rb +2 -1
- data/lib/temporalio/api/nexus/v1/message.rb +2 -1
- data/lib/temporalio/api/nexusoperation/v1/message.rb +26 -0
- data/lib/temporalio/api/notificationservice/v1/request_response.rb +25 -0
- data/lib/temporalio/api/payload_visitor.rb +54 -0
- data/lib/temporalio/api/replication/v1/message.rb +2 -1
- data/lib/temporalio/api/update/v1/message.rb +2 -1
- data/lib/temporalio/api/worker/v1/message.rb +1 -1
- data/lib/temporalio/api/workflow/v1/message.rb +2 -1
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +2 -1
- data/lib/temporalio/client/activity_execution.rb +1 -5
- data/lib/temporalio/client/activity_execution_count.rb +0 -4
- data/lib/temporalio/client/activity_execution_status.rb +0 -2
- data/lib/temporalio/client/activity_handle.rb +9 -6
- data/lib/temporalio/client/activity_id_reference.rb +0 -4
- data/lib/temporalio/client/interceptor.rb +1 -29
- data/lib/temporalio/client/pending_activity_state.rb +0 -2
- data/lib/temporalio/client/schedule.rb +8 -7
- data/lib/temporalio/client/with_start_workflow_operation.rb +1 -1
- data/lib/temporalio/client.rb +10 -20
- data/lib/temporalio/common_enums.rb +0 -4
- data/lib/temporalio/converters/external_storage.rb +90 -0
- data/lib/temporalio/converters/external_storage_concurrency.rb +52 -0
- data/lib/temporalio/converters/storage_driver.rb +56 -0
- data/lib/temporalio/converters/storage_driver_activity_info.rb +38 -0
- data/lib/temporalio/converters/storage_driver_claim.rb +30 -0
- data/lib/temporalio/converters/storage_driver_limiter.rb +37 -0
- data/lib/temporalio/converters/storage_driver_retrieve_context.rb +30 -0
- data/lib/temporalio/converters/storage_driver_select_context.rb +26 -0
- data/lib/temporalio/converters/storage_driver_store_context.rb +31 -0
- data/lib/temporalio/converters/storage_driver_workflow_info.rb +40 -0
- data/lib/temporalio/converters.rb +11 -0
- data/lib/temporalio/error/failure.rb +16 -2
- data/lib/temporalio/error.rb +17 -2
- data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +2 -1
- data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +1 -1
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +1 -1
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +2 -1
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +3 -1
- data/lib/temporalio/internal/client/implementation.rb +6 -1
- data/lib/temporalio/internal/external_storage_references.rb +62 -0
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +2 -0
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +21 -3
- data/lib/temporalio/testing/activity_environment.rb +1 -1
- data/lib/temporalio/testing/workflow_environment.rb +4 -4
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/versioning_override.rb +28 -1
- data/lib/temporalio/worker/interceptor.rb +1 -0
- data/lib/temporalio/workflow.rb +14 -4
- data/rbi/temporalio/api/activity/v1/message.rbi +39 -2
- data/rbi/temporalio/api/callback/v1/message.rbi +22 -2
- data/rbi/temporalio/api/common/v1/message.rbi +294 -4
- data/rbi/temporalio/api/compute/v1/config.rbi +39 -5
- data/rbi/temporalio/api/enums/v1/common.rbi +1 -0
- data/rbi/temporalio/api/enums/v1/failed_cause.rbi +20 -0
- data/rbi/temporalio/api/export/v1/message.rbi +136 -2
- data/rbi/temporalio/api/history/v1/message.rbi +38 -4
- data/rbi/temporalio/api/nexus/v1/message.rbi +88 -0
- data/rbi/temporalio/api/nexusoperation/v1/message.rbi +287 -0
- data/rbi/temporalio/api/notificationservice/v1/request_response.rbi +151 -0
- data/rbi/temporalio/api/payload_visitor.rbi +21 -0
- data/rbi/temporalio/api/replication/v1/message.rbi +22 -2
- data/rbi/temporalio/api/update/v1/message.rbi +19 -2
- data/rbi/temporalio/api/worker/v1/message.rbi +2 -0
- data/rbi/temporalio/api/workflow/v1/message.rbi +41 -4
- data/rbi/temporalio/api/workflowservice/v1/request_response.rbi +294 -20
- data/rbi/temporalio/api/workflowservice/v1/service_services.rbi +0 -13
- data/rbi/temporalio/client/activity_execution.rbi +1 -1
- data/rbi/temporalio/client/interceptor.rbi +1 -1
- data/rbi/temporalio/client/schedule.rbi +2 -2
- data/rbi/temporalio/client.rbi +4 -4
- data/rbi/temporalio/converters/external_storage.rbi +49 -0
- data/rbi/temporalio/converters/external_storage_concurrency.rbi +26 -0
- data/rbi/temporalio/converters/storage_driver.rbi +27 -0
- data/rbi/temporalio/converters/storage_driver_activity_info.rbi +36 -0
- data/rbi/temporalio/converters/storage_driver_claim.rbi +20 -0
- data/rbi/temporalio/converters/storage_driver_limiter.rbi +13 -0
- data/rbi/temporalio/converters/storage_driver_retrieve_context.rbi +23 -0
- data/rbi/temporalio/converters/storage_driver_select_context.rbi +42 -0
- data/rbi/temporalio/converters/storage_driver_store_context.rbi +46 -0
- data/rbi/temporalio/converters/storage_driver_workflow_info.rbi +36 -0
- data/rbi/temporalio/error.rbi +17 -0
- data/rbi/temporalio/internal/bridge/api/activity_result/activity_result.rbi +41 -2
- data/rbi/temporalio/internal/bridge/api/child_workflow/child_workflow.rbi +2 -0
- data/rbi/temporalio/internal/bridge/api/external_data/external_data.rbi +29 -2
- data/rbi/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rbi +88 -14
- data/rbi/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rbi +91 -6
- data/rbi/temporalio/internal/external_storage_references.rbi +26 -0
- data/rbi/temporalio/internal/worker/workflow_instance/context.rbi +2 -0
- data/rbi/temporalio/versioning_override.rbi +8 -0
- data/rbi/temporalio/worker/interceptor.rbi +3 -0
- data/rbi/temporalio/workflow.rbi +4 -0
- data/sig/temporalio/api/activity/v1/message.rbs +18 -0
- data/sig/temporalio/api/callback/v1/message.rbs +10 -0
- data/sig/temporalio/api/common/v1/message.rbs +133 -4
- data/sig/temporalio/api/compute/v1/config.rbs +17 -1
- data/sig/temporalio/api/enums/v1/common.rbs +7 -4
- data/sig/temporalio/api/enums/v1/failed_cause.rbs +42 -5
- data/sig/temporalio/api/export/v1/message.rbs +50 -2
- data/sig/temporalio/api/history/v1/message.rbs +19 -0
- data/sig/temporalio/api/nexus/v1/message.rbs +37 -0
- data/sig/temporalio/api/nexusoperation/v1/message.rbs +125 -0
- data/sig/temporalio/api/notificationservice/v1/request_response.rbs +81 -0
- data/sig/temporalio/api/payload_visitor.rbs +7 -0
- data/sig/temporalio/api/replication/v1/message.rbs +11 -0
- data/sig/temporalio/api/update/v1/message.rbs +9 -0
- data/sig/temporalio/api/worker/v1/message.rbs +9 -3
- data/sig/temporalio/api/workflow/v1/message.rbs +19 -0
- data/sig/temporalio/api/workflowservice/v1/request_response.rbs +136 -0
- data/sig/temporalio/client/activity_execution.rbs +1 -1
- data/sig/temporalio/client/interceptor.rbs +2 -2
- data/sig/temporalio/client/schedule.rbs +3 -2
- data/sig/temporalio/client.rbs +2 -2
- data/sig/temporalio/converters/external_storage.rbs +25 -0
- data/sig/temporalio/converters/external_storage_concurrency.rbs +16 -0
- data/sig/temporalio/converters/storage_driver.rbs +16 -0
- data/sig/temporalio/converters/storage_driver_activity_info.rbs +17 -0
- data/sig/temporalio/converters/storage_driver_claim.rbs +9 -0
- data/sig/temporalio/converters/storage_driver_limiter.rbs +7 -0
- data/sig/temporalio/converters/storage_driver_retrieve_context.rbs +13 -0
- data/sig/temporalio/converters/storage_driver_select_context.rbs +13 -0
- data/sig/temporalio/converters/storage_driver_store_context.rbs +15 -0
- data/sig/temporalio/converters/storage_driver_target_info.rbs +5 -0
- data/sig/temporalio/converters/storage_driver_workflow_info.rbs +17 -0
- data/sig/temporalio/error/failure.rbs +8 -0
- data/sig/temporalio/error.rbs +4 -0
- data/sig/temporalio/internal/bridge/api/activity_result/activity_result.rbs +46 -0
- data/sig/temporalio/internal/bridge/api/child_workflow/child_workflow.rbs +7 -3
- data/sig/temporalio/internal/bridge/api/external_data/external_data.rbs +16 -0
- data/sig/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rbs +42 -2
- data/sig/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rbs +42 -0
- data/sig/temporalio/internal/external_storage_references.rbs +18 -0
- data/sig/temporalio/internal/worker/workflow_instance/context.rbs +1 -0
- data/sig/temporalio/testing/activity_environment.rbs +1 -1
- data/sig/temporalio/versioning_override.rbs +7 -0
- data/sig/temporalio/worker/interceptor.rbs +2 -0
- data/sig/temporalio/workflow.rbs +2 -0
- data/temporalio.gemspec +1 -0
- metadata +56 -2
|
@@ -260,8 +260,6 @@ module Temporalio
|
|
|
260
260
|
)
|
|
261
261
|
|
|
262
262
|
# Input for {Outbound.start_activity}.
|
|
263
|
-
#
|
|
264
|
-
# WARNING: Standalone Activities are experimental.
|
|
265
263
|
StartActivityInput = Data.define(
|
|
266
264
|
:activity,
|
|
267
265
|
:args,
|
|
@@ -275,7 +273,7 @@ module Temporalio
|
|
|
275
273
|
:id_conflict_policy,
|
|
276
274
|
:retry_policy,
|
|
277
275
|
:search_attributes,
|
|
278
|
-
:
|
|
276
|
+
:summary,
|
|
279
277
|
:static_details,
|
|
280
278
|
:headers,
|
|
281
279
|
:priority,
|
|
@@ -286,8 +284,6 @@ module Temporalio
|
|
|
286
284
|
)
|
|
287
285
|
|
|
288
286
|
# Input for {Outbound.describe_activity}.
|
|
289
|
-
#
|
|
290
|
-
# WARNING: Standalone Activities are experimental.
|
|
291
287
|
DescribeActivityInput = Data.define(
|
|
292
288
|
:activity_id,
|
|
293
289
|
:activity_run_id,
|
|
@@ -299,8 +295,6 @@ module Temporalio
|
|
|
299
295
|
)
|
|
300
296
|
|
|
301
297
|
# Input for {Outbound.cancel_activity}.
|
|
302
|
-
#
|
|
303
|
-
# WARNING: Standalone Activities are experimental.
|
|
304
298
|
CancelActivityInput = Data.define(
|
|
305
299
|
:activity_id,
|
|
306
300
|
:activity_run_id,
|
|
@@ -309,8 +303,6 @@ module Temporalio
|
|
|
309
303
|
)
|
|
310
304
|
|
|
311
305
|
# Input for {Outbound.terminate_activity}.
|
|
312
|
-
#
|
|
313
|
-
# WARNING: Standalone Activities are experimental.
|
|
314
306
|
TerminateActivityInput = Data.define(
|
|
315
307
|
:activity_id,
|
|
316
308
|
:activity_run_id,
|
|
@@ -352,16 +344,12 @@ module Temporalio
|
|
|
352
344
|
)
|
|
353
345
|
|
|
354
346
|
# Input for {Outbound.list_activities}.
|
|
355
|
-
#
|
|
356
|
-
# WARNING: Standalone Activities are experimental.
|
|
357
347
|
ListActivitiesInput = Data.define(
|
|
358
348
|
:query,
|
|
359
349
|
:rpc_options
|
|
360
350
|
)
|
|
361
351
|
|
|
362
352
|
# Input for {Outbound.count_activities}.
|
|
363
|
-
#
|
|
364
|
-
# WARNING: Standalone Activities are experimental.
|
|
365
353
|
CountActivitiesInput = Data.define(
|
|
366
354
|
:query,
|
|
367
355
|
:rpc_options
|
|
@@ -369,8 +357,6 @@ module Temporalio
|
|
|
369
357
|
|
|
370
358
|
# Input for {Outbound.fetch_activity_outcome}. Used by `ActivityHandle#result` for long-polling
|
|
371
359
|
# the activity outcome via `PollActivityExecution`.
|
|
372
|
-
#
|
|
373
|
-
# WARNING: Standalone Activities are experimental.
|
|
374
360
|
FetchActivityOutcomeInput = Data.define(
|
|
375
361
|
:activity_id,
|
|
376
362
|
:activity_run_id,
|
|
@@ -588,8 +574,6 @@ module Temporalio
|
|
|
588
574
|
|
|
589
575
|
# Called for every {Client.start_activity} and {Client.execute_activity} call.
|
|
590
576
|
#
|
|
591
|
-
# WARNING: Standalone Activities are experimental.
|
|
592
|
-
#
|
|
593
577
|
# @param input [StartActivityInput] Input.
|
|
594
578
|
# @return [ActivityHandle] Activity handle.
|
|
595
579
|
def start_activity(input)
|
|
@@ -598,8 +582,6 @@ module Temporalio
|
|
|
598
582
|
|
|
599
583
|
# Called for every {ActivityHandle.describe} call.
|
|
600
584
|
#
|
|
601
|
-
# WARNING: Standalone Activities are experimental.
|
|
602
|
-
#
|
|
603
585
|
# @param input [DescribeActivityInput] Input.
|
|
604
586
|
# @return [ActivityExecution::Description] Activity description.
|
|
605
587
|
def describe_activity(input)
|
|
@@ -608,8 +590,6 @@ module Temporalio
|
|
|
608
590
|
|
|
609
591
|
# Called for every {ActivityHandle.cancel} call.
|
|
610
592
|
#
|
|
611
|
-
# WARNING: Standalone Activities are experimental.
|
|
612
|
-
#
|
|
613
593
|
# @param input [CancelActivityInput] Input.
|
|
614
594
|
def cancel_activity(input)
|
|
615
595
|
next_interceptor.cancel_activity(input)
|
|
@@ -617,8 +597,6 @@ module Temporalio
|
|
|
617
597
|
|
|
618
598
|
# Called for every {ActivityHandle.terminate} call.
|
|
619
599
|
#
|
|
620
|
-
# WARNING: Standalone Activities are experimental.
|
|
621
|
-
#
|
|
622
600
|
# @param input [TerminateActivityInput] Input.
|
|
623
601
|
def terminate_activity(input)
|
|
624
602
|
next_interceptor.terminate_activity(input)
|
|
@@ -654,8 +632,6 @@ module Temporalio
|
|
|
654
632
|
|
|
655
633
|
# Called for every {Client.list_activities} call.
|
|
656
634
|
#
|
|
657
|
-
# WARNING: Standalone Activities are experimental.
|
|
658
|
-
#
|
|
659
635
|
# @param input [ListActivitiesInput] Input.
|
|
660
636
|
# @return [Enumerator<ActivityExecution>] Activity executions.
|
|
661
637
|
def list_activities(input)
|
|
@@ -664,8 +640,6 @@ module Temporalio
|
|
|
664
640
|
|
|
665
641
|
# Called for every {Client.count_activities} call.
|
|
666
642
|
#
|
|
667
|
-
# WARNING: Standalone Activities are experimental.
|
|
668
|
-
#
|
|
669
643
|
# @param input [CountActivitiesInput] Input.
|
|
670
644
|
# @return [ActivityExecutionCount] Activity count.
|
|
671
645
|
def count_activities(input)
|
|
@@ -674,8 +648,6 @@ module Temporalio
|
|
|
674
648
|
|
|
675
649
|
# Called by {ActivityHandle.result} to long-poll the activity outcome.
|
|
676
650
|
#
|
|
677
|
-
# WARNING: Standalone Activities are experimental.
|
|
678
|
-
#
|
|
679
651
|
# @param input [FetchActivityOutcomeInput] Input.
|
|
680
652
|
# @return [Api::Activity::V1::ActivityExecutionOutcome] Activity outcome.
|
|
681
653
|
def fetch_activity_outcome(input)
|
|
@@ -5,8 +5,6 @@ require 'temporalio/api'
|
|
|
5
5
|
module Temporalio
|
|
6
6
|
class Client
|
|
7
7
|
# More detailed breakdown of a running activity's state.
|
|
8
|
-
#
|
|
9
|
-
# WARNING: Standalone Activities are experimental.
|
|
10
8
|
module PendingActivityState
|
|
11
9
|
SCHEDULED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_SCHEDULED
|
|
12
10
|
STARTED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_STARTED
|
|
@@ -211,7 +211,7 @@ module Temporalio
|
|
|
211
211
|
# @!attribute search_attributes
|
|
212
212
|
# @return [SearchAttributes, nil] Search attributes for the workflow.
|
|
213
213
|
# @!attribute priority
|
|
214
|
-
# @return [Priority] Priority of the workflow.
|
|
214
|
+
# @return [Priority] Priority of the workflow.
|
|
215
215
|
# @!attribute arg_hints
|
|
216
216
|
# @return [Array<Object>, nil] Converter hints for workflow arguments. This is only user-set (e.g. on create)
|
|
217
217
|
# and is not persisted and therefore will not be set when describing a workflow.
|
|
@@ -242,7 +242,7 @@ module Temporalio
|
|
|
242
242
|
# @param retry_policy [RetryPolicy, nil] Retry policy for the workflow.
|
|
243
243
|
# @param memo [Hash<String, Object>, nil] Memo for the workflow.
|
|
244
244
|
# @param search_attributes [SearchAttributes, nil] Search attributes for the workflow.
|
|
245
|
-
# @param priority [Priority] Priority of the workflow.
|
|
245
|
+
# @param priority [Priority] Priority of the workflow.
|
|
246
246
|
# @param headers [Hash<String, Object>, nil] Headers for the workflow.
|
|
247
247
|
def new(
|
|
248
248
|
workflow,
|
|
@@ -732,7 +732,8 @@ module Temporalio
|
|
|
732
732
|
# @!attribute overlap
|
|
733
733
|
# @return [OverlapPolicy] Controls what happens when an action is started while another is still running.
|
|
734
734
|
# @!attribute catchup_window
|
|
735
|
-
# @return [Float] After a Temporal server is unavailable, amount of time in the past to execute missed
|
|
735
|
+
# @return [Float, nil] After a Temporal server is unavailable, amount of time in the past to execute missed
|
|
736
|
+
# actions. If nil, the server-configured default applies (currently one year).
|
|
736
737
|
# @!attribute pause_on_failure
|
|
737
738
|
# @return [Boolean] Whether to pause the schedule if an action fails or times out. Note: For workflows, this
|
|
738
739
|
# only applies after all retries have been exhausted.
|
|
@@ -743,7 +744,7 @@ module Temporalio
|
|
|
743
744
|
overlap: Internal::ProtoUtils.enum_to_int(Api::Enums::V1::ScheduleOverlapPolicy,
|
|
744
745
|
raw_policies.overlap_policy,
|
|
745
746
|
zero_means_nil: true),
|
|
746
|
-
catchup_window: Internal::ProtoUtils.duration_to_seconds(raw_policies.catchup_window)
|
|
747
|
+
catchup_window: Internal::ProtoUtils.duration_to_seconds(raw_policies.catchup_window),
|
|
747
748
|
pause_on_failure: raw_policies.pause_on_failure
|
|
748
749
|
)
|
|
749
750
|
end
|
|
@@ -751,13 +752,13 @@ module Temporalio
|
|
|
751
752
|
# Create a schedule policy.
|
|
752
753
|
#
|
|
753
754
|
# @param overlap [OverlapPolicy] Controls what happens when an action is started while another is still running.
|
|
754
|
-
# @param catchup_window [Float] After a Temporal server is unavailable, amount of time in the past to
|
|
755
|
-
# missed actions.
|
|
755
|
+
# @param catchup_window [Float, nil] After a Temporal server is unavailable, amount of time in the past to
|
|
756
|
+
# execute missed actions. If nil, the server-configured default applies. An explicit zero is sent.
|
|
756
757
|
# @param pause_on_failure [Boolean] Whether to pause the schedule if an action fails or times out. Note: For
|
|
757
758
|
# workflows, this only applies after all retries have been exhausted.
|
|
758
759
|
def initialize(
|
|
759
760
|
overlap: OverlapPolicy::SKIP,
|
|
760
|
-
catchup_window:
|
|
761
|
+
catchup_window: nil,
|
|
761
762
|
pause_on_failure: false
|
|
762
763
|
)
|
|
763
764
|
super
|
|
@@ -43,7 +43,7 @@ module Temporalio
|
|
|
43
43
|
# Note, for {Client.start_update_with_start_workflow} and {Client.execute_update_with_start_workflow},
|
|
44
44
|
# `id_conflict_policy` is required.
|
|
45
45
|
#
|
|
46
|
-
# @param priority [Priority] Priority of the workflow that may be started.
|
|
46
|
+
# @param priority [Priority] Priority of the workflow that may be started.
|
|
47
47
|
def initialize(
|
|
48
48
|
workflow,
|
|
49
49
|
*args,
|
data/lib/temporalio/client.rb
CHANGED
|
@@ -308,7 +308,7 @@ module Temporalio
|
|
|
308
308
|
# @param request_eager_start [Boolean] Potentially reduce the latency to start this workflow by encouraging the
|
|
309
309
|
# server to start it on a local worker running with this same client. This is currently experimental.
|
|
310
310
|
# @param versioning_override [VersioningOverride, nil] Override the version of the workflow.
|
|
311
|
-
# @param priority [Priority] Priority of the workflow.
|
|
311
|
+
# @param priority [Priority] Priority of the workflow.
|
|
312
312
|
# @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
|
|
313
313
|
# workflow definition has arg hints, those are used by default.
|
|
314
314
|
# @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the workflow
|
|
@@ -400,7 +400,7 @@ module Temporalio
|
|
|
400
400
|
# @param request_eager_start [Boolean] Potentially reduce the latency to start this workflow by encouraging the
|
|
401
401
|
# server to start it on a local worker running with this same client. This is currently experimental.
|
|
402
402
|
# @param versioning_override [VersioningOverride, nil] Override the version of the workflow.
|
|
403
|
-
# @param priority [Priority] Priority for the workflow.
|
|
403
|
+
# @param priority [Priority] Priority for the workflow.
|
|
404
404
|
# @param arg_hints [Array<Object>, nil] Overrides converter hints for arguments if any. If unset/nil and the
|
|
405
405
|
# workflow definition has arg hints, those are used by default.
|
|
406
406
|
# @param result_hint [Object, nil] Overrides converter hint for result if any. If unset/nil and the workflow
|
|
@@ -485,8 +485,6 @@ module Temporalio
|
|
|
485
485
|
# Get a handle for an existing standalone activity. Useful when the activity was started elsewhere
|
|
486
486
|
# (a different process, or by another client) and you have only its ID.
|
|
487
487
|
#
|
|
488
|
-
# WARNING: Standalone Activities are experimental.
|
|
489
|
-
#
|
|
490
488
|
# @param activity_id [String] ID for the activity.
|
|
491
489
|
# @param activity_run_id [String, nil] Run ID for the activity execution. If nil, operations target the
|
|
492
490
|
# latest run of the given activity ID.
|
|
@@ -500,8 +498,6 @@ module Temporalio
|
|
|
500
498
|
|
|
501
499
|
# Start a standalone activity execution and return its handle.
|
|
502
500
|
#
|
|
503
|
-
# WARNING: Standalone Activities are experimental.
|
|
504
|
-
#
|
|
505
501
|
# @param activity [Class<Activity::Definition>, Activity::Definition, Activity::Definition::Info, Symbol, String]
|
|
506
502
|
# Activity definition, definition class or activity name.
|
|
507
503
|
# @param args [Array<Object>] Arguments to the activity.
|
|
@@ -519,9 +515,9 @@ module Temporalio
|
|
|
519
515
|
# is currently running. Defaults to `FAIL` (reject the start attempt).
|
|
520
516
|
# @param retry_policy [RetryPolicy, nil] Retry policy for the activity.
|
|
521
517
|
# @param search_attributes [SearchAttributes, nil] Search attributes for the activity.
|
|
522
|
-
# @param
|
|
518
|
+
# @param summary [String, nil] Fixed single-line summary for this activity execution.
|
|
523
519
|
# @param static_details [String, nil] Fixed details for this activity execution. May be in markdown format.
|
|
524
|
-
# @param priority [Priority] Priority for the activity.
|
|
520
|
+
# @param priority [Priority] Priority for the activity.
|
|
525
521
|
# @param start_delay [Float, nil] Time (in seconds) to wait before dispatching the first activity task. This delay
|
|
526
522
|
# is not applied to retry attempts. `nil` or `0` means no delay. Negative values raise `ArgumentError`.
|
|
527
523
|
# This is currently experimental.
|
|
@@ -545,7 +541,7 @@ module Temporalio
|
|
|
545
541
|
id_conflict_policy: ActivityIDConflictPolicy::FAIL,
|
|
546
542
|
retry_policy: nil,
|
|
547
543
|
search_attributes: nil,
|
|
548
|
-
|
|
544
|
+
summary: nil,
|
|
549
545
|
static_details: nil,
|
|
550
546
|
priority: Priority.default,
|
|
551
547
|
start_delay: nil,
|
|
@@ -568,7 +564,7 @@ module Temporalio
|
|
|
568
564
|
id_conflict_policy:,
|
|
569
565
|
retry_policy:,
|
|
570
566
|
search_attributes:,
|
|
571
|
-
|
|
567
|
+
summary:,
|
|
572
568
|
static_details:,
|
|
573
569
|
headers: {},
|
|
574
570
|
priority:,
|
|
@@ -582,8 +578,6 @@ module Temporalio
|
|
|
582
578
|
# Start a standalone activity execution and wait for its result. Shortcut for
|
|
583
579
|
# {start_activity} + {ActivityHandle#result}.
|
|
584
580
|
#
|
|
585
|
-
# WARNING: Standalone Activities are experimental.
|
|
586
|
-
#
|
|
587
581
|
# @param activity [Class<Activity::Definition>, Activity::Definition, Activity::Definition::Info, Symbol, String]
|
|
588
582
|
# Activity definition, definition class or activity name.
|
|
589
583
|
# @param args [Array<Object>] Arguments to the activity.
|
|
@@ -601,9 +595,9 @@ module Temporalio
|
|
|
601
595
|
# is currently running. Defaults to `FAIL` (reject the start attempt).
|
|
602
596
|
# @param retry_policy [RetryPolicy, nil] Retry policy for the activity.
|
|
603
597
|
# @param search_attributes [SearchAttributes, nil] Search attributes for the activity.
|
|
604
|
-
# @param
|
|
598
|
+
# @param summary [String, nil] Fixed single-line summary for this activity execution.
|
|
605
599
|
# @param static_details [String, nil] Fixed details for this activity execution. May be in markdown format.
|
|
606
|
-
# @param priority [Priority] Priority for the activity.
|
|
600
|
+
# @param priority [Priority] Priority for the activity.
|
|
607
601
|
# @param start_delay [Float, nil] Time (in seconds) to wait before dispatching the first activity task. This delay
|
|
608
602
|
# is not applied to retry attempts. `nil` or `0` means no delay. Negative values raise `ArgumentError`.
|
|
609
603
|
# This is currently experimental.
|
|
@@ -628,7 +622,7 @@ module Temporalio
|
|
|
628
622
|
id_conflict_policy: ActivityIDConflictPolicy::FAIL,
|
|
629
623
|
retry_policy: nil,
|
|
630
624
|
search_attributes: nil,
|
|
631
|
-
|
|
625
|
+
summary: nil,
|
|
632
626
|
static_details: nil,
|
|
633
627
|
priority: Priority.default,
|
|
634
628
|
start_delay: nil,
|
|
@@ -649,7 +643,7 @@ module Temporalio
|
|
|
649
643
|
id_conflict_policy:,
|
|
650
644
|
retry_policy:,
|
|
651
645
|
search_attributes:,
|
|
652
|
-
|
|
646
|
+
summary:,
|
|
653
647
|
static_details:,
|
|
654
648
|
priority:,
|
|
655
649
|
start_delay:,
|
|
@@ -661,8 +655,6 @@ module Temporalio
|
|
|
661
655
|
|
|
662
656
|
# List standalone activities matching a visibility query.
|
|
663
657
|
#
|
|
664
|
-
# WARNING: Standalone Activities are experimental.
|
|
665
|
-
#
|
|
666
658
|
# @param query [String] Visibility list filter.
|
|
667
659
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
|
668
660
|
#
|
|
@@ -674,8 +666,6 @@ module Temporalio
|
|
|
674
666
|
|
|
675
667
|
# Count standalone activities matching a visibility query.
|
|
676
668
|
#
|
|
677
|
-
# WARNING: Standalone Activities are experimental.
|
|
678
|
-
#
|
|
679
669
|
# @param query [String] Visibility list filter.
|
|
680
670
|
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
|
681
671
|
#
|
|
@@ -86,8 +86,6 @@ module Temporalio
|
|
|
86
86
|
|
|
87
87
|
# Controls behavior when an activity with the same ID was previously run and is now closed.
|
|
88
88
|
#
|
|
89
|
-
# WARNING: Standalone Activities are experimental.
|
|
90
|
-
#
|
|
91
89
|
# @see https://docs.temporal.io/activities
|
|
92
90
|
module ActivityIDReusePolicy
|
|
93
91
|
# Always allow starting an activity using the same activity ID.
|
|
@@ -102,8 +100,6 @@ module Temporalio
|
|
|
102
100
|
|
|
103
101
|
# Controls behavior when an activity with the same ID is currently running.
|
|
104
102
|
#
|
|
105
|
-
# WARNING: Standalone Activities are experimental.
|
|
106
|
-
#
|
|
107
103
|
# @see https://docs.temporal.io/activities
|
|
108
104
|
module ActivityIDConflictPolicy
|
|
109
105
|
# Don't start a new activity; instead fail with already-started error.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'temporalio/converters/external_storage_concurrency'
|
|
4
|
+
require 'temporalio/converters/storage_driver'
|
|
5
|
+
|
|
6
|
+
module Temporalio
|
|
7
|
+
module Converters
|
|
8
|
+
# Configuration for offloading large payloads to an external storage system.
|
|
9
|
+
#
|
|
10
|
+
# This is validated when constructed rather than when used, so a misconfiguration surfaces at startup instead of on
|
|
11
|
+
# the first payload large enough to offload.
|
|
12
|
+
#
|
|
13
|
+
# @note WARNING: This API is experimental and may change in the future.
|
|
14
|
+
#
|
|
15
|
+
# @!visibility private
|
|
16
|
+
class ExternalStorage
|
|
17
|
+
# Shared with every other SDK, so the same payload offloads regardless of which one wrote it.
|
|
18
|
+
DEFAULT_PAYLOAD_SIZE_THRESHOLD = 256 * 1024
|
|
19
|
+
|
|
20
|
+
# @return [Array<StorageDriver>] Drivers available for storing and retrieving payloads.
|
|
21
|
+
attr_reader :drivers
|
|
22
|
+
|
|
23
|
+
# @return [Proc] Selector choosing which driver stores each payload. Called with a
|
|
24
|
+
# {StorageDriverSelectContext} and a payload, returning a {StorageDriver} or nil to pass the payload through.
|
|
25
|
+
# Only called for payloads that meet {#payload_size_threshold}, and must return one of {#drivers} or nil.
|
|
26
|
+
attr_reader :driver_selector
|
|
27
|
+
|
|
28
|
+
# @return [ExternalStorageConcurrency] Limits on how many storage requests may be in flight at once.
|
|
29
|
+
attr_reader :concurrency
|
|
30
|
+
|
|
31
|
+
# @return [Integer] Minimum encoded payload size, in bytes, that is offloaded. Payloads at or above this size are
|
|
32
|
+
# offloaded; smaller ones are left inline. Zero offloads every payload.
|
|
33
|
+
attr_reader :payload_size_threshold
|
|
34
|
+
|
|
35
|
+
# Create external storage configuration.
|
|
36
|
+
#
|
|
37
|
+
# @param drivers [Array<StorageDriver>] Drivers available for storing and retrieving payloads. At least one is
|
|
38
|
+
# required, and every driver must have a unique, non-empty name. Retrieval routes by the name recorded in
|
|
39
|
+
# history, so a driver must remain configured for as long as any payload it stored can still be read.
|
|
40
|
+
# @param driver_selector [Proc, nil] Selector choosing which driver stores each payload. Required when more than
|
|
41
|
+
# one driver is given; with a single driver it may be nil, in which case that driver stores every eligible
|
|
42
|
+
# payload.
|
|
43
|
+
# @param payload_size_threshold [Integer] Minimum encoded payload size, in bytes, to offload. Must be a
|
|
44
|
+
# non-negative Integer.
|
|
45
|
+
# @param concurrency [ExternalStorageConcurrency] Limits on how many storage requests may be in flight at once.
|
|
46
|
+
def initialize(
|
|
47
|
+
drivers:,
|
|
48
|
+
driver_selector: nil,
|
|
49
|
+
payload_size_threshold: DEFAULT_PAYLOAD_SIZE_THRESHOLD,
|
|
50
|
+
concurrency: ExternalStorageConcurrency.new
|
|
51
|
+
)
|
|
52
|
+
raise ArgumentError, 'At least one driver is required' if drivers.empty?
|
|
53
|
+
|
|
54
|
+
unless payload_size_threshold.is_a?(Integer) && payload_size_threshold >= 0
|
|
55
|
+
raise ArgumentError, 'payload_size_threshold must be a non-negative Integer'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if drivers.size > 1 && driver_selector.nil?
|
|
59
|
+
raise ArgumentError, 'driver_selector is required when more than one driver is given'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
@drivers_by_name = {}
|
|
63
|
+
drivers.each do |driver|
|
|
64
|
+
name = driver.name
|
|
65
|
+
# The name is the routing key written into history and is written to a string proto field, so anything but
|
|
66
|
+
# a non-empty String cannot be resolved on read. A Symbol in particular passes a bare empty? check.
|
|
67
|
+
raise ArgumentError, 'Driver name must be a non-empty String' unless name.is_a?(String) && !name.empty?
|
|
68
|
+
raise ArgumentError, "Multiple drivers given with name '#{name}'" if @drivers_by_name.key?(name)
|
|
69
|
+
|
|
70
|
+
@drivers_by_name[name] = driver
|
|
71
|
+
end
|
|
72
|
+
@drivers_by_name.freeze
|
|
73
|
+
|
|
74
|
+
@drivers = drivers.dup.freeze
|
|
75
|
+
# Normalized so callers never have to distinguish the single-driver case.
|
|
76
|
+
@driver_selector = driver_selector || ->(_context, _payload) { @drivers.first }
|
|
77
|
+
@payload_size_threshold = payload_size_threshold
|
|
78
|
+
@concurrency = concurrency
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Get the driver registered under the given name.
|
|
82
|
+
#
|
|
83
|
+
# @param name [String] Driver name recorded in the payload reference.
|
|
84
|
+
# @return [StorageDriver, nil] The driver, or nil if none is registered under that name.
|
|
85
|
+
def driver(name)
|
|
86
|
+
@drivers_by_name[name]
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Temporalio
|
|
4
|
+
module Converters
|
|
5
|
+
ExternalStorageConcurrency = Data.define(
|
|
6
|
+
:max_driver_operations,
|
|
7
|
+
:max_operations_per_message
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
# Limits on how many external storage requests may be in flight at once. Set on
|
|
11
|
+
# {ExternalStorage#concurrency}.
|
|
12
|
+
#
|
|
13
|
+
# @note WARNING: This API is experimental and may change in the future.
|
|
14
|
+
#
|
|
15
|
+
# @!attribute [r] max_driver_operations
|
|
16
|
+
# @return [Integer] Maximum requests in flight at once across every driver registered on the owning
|
|
17
|
+
# {ExternalStorage}. Each worker and each client gets its own budget of this size.
|
|
18
|
+
# @!attribute [r] max_operations_per_message
|
|
19
|
+
# @return [Integer] Maximum requests in flight at once on behalf of a single message, such as one workflow task
|
|
20
|
+
# activation, activity task, Nexus operation, or client request. Every message gets its own budget of this
|
|
21
|
+
# size, which stops a message carrying many large payloads from starving the rest.
|
|
22
|
+
#
|
|
23
|
+
# @!visibility private
|
|
24
|
+
class ExternalStorageConcurrency
|
|
25
|
+
# Shared with every other SDK.
|
|
26
|
+
DEFAULT_MAX_DRIVER_OPERATIONS = 64
|
|
27
|
+
|
|
28
|
+
# Shared with every other SDK.
|
|
29
|
+
DEFAULT_MAX_OPERATIONS_PER_MESSAGE = 8
|
|
30
|
+
|
|
31
|
+
# Create concurrency limits.
|
|
32
|
+
#
|
|
33
|
+
# @param max_driver_operations [Integer] Maximum requests in flight across the configuration.
|
|
34
|
+
# @param max_operations_per_message [Integer] Maximum requests in flight for one message.
|
|
35
|
+
def initialize(
|
|
36
|
+
max_driver_operations: DEFAULT_MAX_DRIVER_OPERATIONS,
|
|
37
|
+
max_operations_per_message: DEFAULT_MAX_OPERATIONS_PER_MESSAGE
|
|
38
|
+
)
|
|
39
|
+
# A budget of zero would stop every storage operation rather than disabling the limit, so it is rejected
|
|
40
|
+
# here instead of deadlocking the first offload.
|
|
41
|
+
unless max_driver_operations.is_a?(Integer) && max_driver_operations >= 1
|
|
42
|
+
raise ArgumentError, 'max_driver_operations must be an Integer of at least 1'
|
|
43
|
+
end
|
|
44
|
+
unless max_operations_per_message.is_a?(Integer) && max_operations_per_message >= 1
|
|
45
|
+
raise ArgumentError, 'max_operations_per_message must be an Integer of at least 1'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
super
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Temporalio
|
|
4
|
+
module Converters
|
|
5
|
+
# Base class for storing and retrieving payloads in an external storage system.
|
|
6
|
+
#
|
|
7
|
+
# Payloads at or over the configured size threshold are handed to a driver and replaced on the wire by a small
|
|
8
|
+
# reference, so the payload data itself never reaches the Temporal server.
|
|
9
|
+
#
|
|
10
|
+
# Implementations are called concurrently and must be thread safe. Methods block, and may perform I/O directly.
|
|
11
|
+
# To work a batch concurrently, fan out with threads: threads overlap blocking I/O, since Ruby releases its global
|
|
12
|
+
# lock around it, and they work whether or not the worker is running under a fiber scheduler.
|
|
13
|
+
# {::Fiber.schedule} must not be used, since it raises when the worker is configured with a payload codec thread
|
|
14
|
+
# pool instead of a fiber scheduler. {Temporalio::Worker::ThreadPool} can be used to bound that fan out.
|
|
15
|
+
#
|
|
16
|
+
# @note WARNING: This API is experimental and may change in the future.
|
|
17
|
+
#
|
|
18
|
+
# @!visibility private
|
|
19
|
+
class StorageDriver
|
|
20
|
+
# Name of this driver instance, unique among the drivers registered on one {ExternalStorage}. This is written
|
|
21
|
+
# into history alongside every payload the driver stores and is used to route retrieval back to the same driver.
|
|
22
|
+
# Renaming a deployed driver makes every payload stored under the old name unretrievable.
|
|
23
|
+
#
|
|
24
|
+
# @return [String] Driver instance name.
|
|
25
|
+
def name
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Identifier for this driver implementation, for example +aws.s3driver+. Unlike {#name}, this is identical across
|
|
30
|
+
# every instance of the same implementation and across SDK languages.
|
|
31
|
+
#
|
|
32
|
+
# @return [String] Driver implementation identifier.
|
|
33
|
+
def type
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Store the given payloads.
|
|
38
|
+
#
|
|
39
|
+
# @param context [StorageDriverStoreContext] Context for this store operation.
|
|
40
|
+
# @param payloads [Enumerable<Api::Common::V1::Payload>] Payloads to store. This value should not be mutated.
|
|
41
|
+
# @return [Array<StorageDriverClaim>] One claim per payload, in the same order.
|
|
42
|
+
def store(context, payloads)
|
|
43
|
+
raise NotImplementedError
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Retrieve the payloads for the given claims.
|
|
47
|
+
#
|
|
48
|
+
# @param context [StorageDriverRetrieveContext] Context for this retrieve operation.
|
|
49
|
+
# @param claims [Enumerable<StorageDriverClaim>] Claims to retrieve. This value should not be mutated.
|
|
50
|
+
# @return [Array<Api::Common::V1::Payload>] One payload per claim, in the same order.
|
|
51
|
+
def retrieve(context, claims)
|
|
52
|
+
raise NotImplementedError
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Temporalio
|
|
4
|
+
module Converters
|
|
5
|
+
StorageDriverActivityInfo = Data.define(
|
|
6
|
+
:namespace,
|
|
7
|
+
:id,
|
|
8
|
+
:run_id,
|
|
9
|
+
:type
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
# Identity of a standalone activity a payload is being stored on behalf of.
|
|
13
|
+
#
|
|
14
|
+
# @note WARNING: This API is experimental and may change in the future.
|
|
15
|
+
#
|
|
16
|
+
# @!attribute [r] namespace
|
|
17
|
+
# @return [String] Activity namespace.
|
|
18
|
+
# @!attribute [r] id
|
|
19
|
+
# @return [String, nil] Activity ID, if known.
|
|
20
|
+
# @!attribute [r] run_id
|
|
21
|
+
# @return [String, nil] Run ID, if known.
|
|
22
|
+
# @!attribute [r] type
|
|
23
|
+
# @return [String, nil] Activity type name, if known.
|
|
24
|
+
#
|
|
25
|
+
# @!visibility private
|
|
26
|
+
class StorageDriverActivityInfo
|
|
27
|
+
# Create activity target information.
|
|
28
|
+
#
|
|
29
|
+
# @param namespace [String] Activity namespace.
|
|
30
|
+
# @param id [String, nil] Activity ID.
|
|
31
|
+
# @param run_id [String, nil] Run ID.
|
|
32
|
+
# @param type [String, nil] Activity type name.
|
|
33
|
+
def initialize(namespace:, id: nil, run_id: nil, type: nil)
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Temporalio
|
|
4
|
+
module Converters
|
|
5
|
+
StorageDriverClaim = Data.define(:claim_data)
|
|
6
|
+
|
|
7
|
+
# Driver-defined reference to an externally stored payload, used to retrieve it later.
|
|
8
|
+
#
|
|
9
|
+
# @note WARNING: This API is experimental and may change in the future.
|
|
10
|
+
#
|
|
11
|
+
# @!attribute [r] claim_data
|
|
12
|
+
# @return [Hash<String, String>] Data the driver needs to retrieve the payload. This is written into history, so
|
|
13
|
+
# it must contain everything required for retrieval and must not contain secrets.
|
|
14
|
+
#
|
|
15
|
+
# @!visibility private
|
|
16
|
+
class StorageDriverClaim
|
|
17
|
+
# Create a claim.
|
|
18
|
+
#
|
|
19
|
+
# @param claim_data [Hash<String, String>] Data identifying the stored payload.
|
|
20
|
+
def initialize(claim_data:)
|
|
21
|
+
# Copied and frozen because a claim is compared and hashed by this data, so a later mutation would silently
|
|
22
|
+
# change its identity. The values are copied individually because freezing the Hash leaves them mutable in
|
|
23
|
+
# place and still aliased to the caller's objects.
|
|
24
|
+
# steep:ignore:start
|
|
25
|
+
super(claim_data: claim_data.transform_values { |value| value.dup.freeze }.freeze)
|
|
26
|
+
# steep:ignore:end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Temporalio
|
|
4
|
+
module Converters
|
|
5
|
+
# Bounds how many external storage requests are in flight at once. The SDK supplies one on
|
|
6
|
+
# {StorageDriverStoreContext} and {StorageDriverRetrieveContext}; a driver calls it rather than
|
|
7
|
+
# implementing it.
|
|
8
|
+
#
|
|
9
|
+
# A driver is handed a whole batch and decides for itself how many requests to make of it, so the SDK cannot
|
|
10
|
+
# bound that fan out on the driver's behalf. The limit is cooperative: a driver that never calls {#permit} makes
|
|
11
|
+
# requests that no budget counts, and the SDK warns when it detects that.
|
|
12
|
+
#
|
|
13
|
+
# @note WARNING: This API is experimental and may change in the future.
|
|
14
|
+
#
|
|
15
|
+
# @!visibility private
|
|
16
|
+
class StorageDriverLimiter
|
|
17
|
+
# Hold a permit for the duration of the given block, waiting for one to be available before the block runs
|
|
18
|
+
# and releasing it when the block returns or raises.
|
|
19
|
+
#
|
|
20
|
+
# Take one permit per request, not one around a whole batch: wrapping a whole fan out in a single permit
|
|
21
|
+
# satisfies this signature while quietly defeating the limit. Taking a permit while already holding one can
|
|
22
|
+
# deadlock once the nesting reaches the configured limit, so a driver must not nest these.
|
|
23
|
+
#
|
|
24
|
+
# Waiting for a permit observes the cancellation on the context this limiter came from, so a driver that is
|
|
25
|
+
# waiting when the SDK abandons the operation stops waiting.
|
|
26
|
+
#
|
|
27
|
+
# @param item [Api::Common::V1::Payload, StorageDriverClaim] What this one request covers: a payload when
|
|
28
|
+
# storing, a claim when retrieving.
|
|
29
|
+
# @yield The request to make while holding the permit.
|
|
30
|
+
# @return [Object] Whatever the block returned.
|
|
31
|
+
# @raise [Error::CanceledError] If cancelled while waiting for a permit.
|
|
32
|
+
def permit(item, &)
|
|
33
|
+
raise NotImplementedError
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|