temporalio 1.11.0 → 1.12.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 +33 -11
- data/Cargo.toml +1 -0
- data/README.md +168 -11
- data/ext/Cargo.toml +3 -3
- data/lib/temporalio/api/cloud/account/v1/message.rb +2 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +43 -1
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +1 -1
- data/lib/temporalio/api/cloud/connectivityrule/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/identity/v1/message.rb +8 -1
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +8 -1
- data/lib/temporalio/api/cloud/nexus/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/project/v1/message.rb +28 -0
- data/lib/temporalio/api/cloud/region/v1/message.rb +1 -1
- data/lib/temporalio/api/cloud/sink/v1/message.rb +2 -1
- data/lib/temporalio/api/enums/v1/failed_cause.rb +1 -1
- data/lib/temporalio/api/enums/v1/namespace.rb +2 -1
- data/lib/temporalio/api/operatorservice/v1/request_response.rb +9 -1
- data/lib/temporalio/api/operatorservice/v1/service.rb +1 -1
- data/lib/temporalio/api/payload_visitor.rb +66 -0
- data/lib/temporalio/api/taskqueue/v1/message.rb +3 -1
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +2 -1
- data/lib/temporalio/api/workflowservice/v1/service.rb +1 -1
- data/lib/temporalio/client/connection/cloud_service.rb +285 -0
- data/lib/temporalio/client/connection/operator_service.rb +45 -0
- data/lib/temporalio/client/schedule.rb +56 -8
- data/lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb +0 -2
- data/lib/temporalio/contrib/aws/s3_driver/s3_storage_driver.rb +3 -5
- data/lib/temporalio/contrib/aws/s3_driver/s3_storage_driver_client.rb +0 -2
- data/lib/temporalio/contrib/aws/s3_driver.rb +0 -2
- data/lib/temporalio/converters/data_converter.rb +52 -1
- data/lib/temporalio/converters/external_storage.rb +6 -12
- data/lib/temporalio/converters/external_storage_concurrency.rb +4 -2
- data/lib/temporalio/converters/storage_driver.rb +3 -4
- data/lib/temporalio/converters/storage_driver_activity_info.rb +0 -2
- data/lib/temporalio/converters/storage_driver_claim.rb +0 -2
- data/lib/temporalio/converters/storage_driver_limiter.rb +16 -0
- data/lib/temporalio/converters/storage_driver_retrieve_context.rb +7 -6
- data/lib/temporalio/converters/storage_driver_select_context.rb +11 -5
- data/lib/temporalio/converters/storage_driver_store_context.rb +11 -7
- data/lib/temporalio/converters/storage_driver_workflow_info.rb +0 -2
- data/lib/temporalio/error.rb +10 -3
- data/lib/temporalio/internal/bridge/worker.rb +1 -0
- data/lib/temporalio/internal/client/described_schedule_action.rb +41 -0
- data/lib/temporalio/internal/client/implementation.rb +92 -48
- data/lib/temporalio/internal/external_storage_references.rb +5 -4
- data/lib/temporalio/internal/external_storage_runner.rb +177 -0
- data/lib/temporalio/internal/storage_operation_metrics.rb +76 -0
- data/lib/temporalio/internal/worker/activity_worker.rb +60 -24
- data/lib/temporalio/internal/worker/workflow_worker.rb +211 -15
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/worker/workflow_replayer.rb +5 -3
- data/lib/temporalio/worker.rb +4 -2
- data/rbi/temporalio/api/cloud/account/v1/message.rbi +84 -2
- data/rbi/temporalio/api/cloud/cloudservice/v1/request_response.rbi +5006 -1157
- data/rbi/temporalio/api/cloud/cloudservice/v1/service_services.rbi +171 -0
- data/rbi/temporalio/api/cloud/connectivityrule/v1/message.rbi +71 -16
- data/rbi/temporalio/api/cloud/identity/v1/message.rbi +789 -23
- data/rbi/temporalio/api/cloud/namespace/v1/message.rbi +765 -15
- data/rbi/temporalio/api/cloud/nexus/v1/message.rbi +19 -2
- data/rbi/temporalio/api/cloud/project/v1/message.rbi +334 -0
- data/rbi/temporalio/api/cloud/region/v1/message.rbi +1 -0
- data/rbi/temporalio/api/cloud/sink/v1/message.rbi +147 -0
- data/rbi/temporalio/api/common/v1/message.rbi +6 -0
- data/rbi/temporalio/api/enums/v1/failed_cause.rbi +2 -0
- data/rbi/temporalio/api/enums/v1/namespace.rbi +20 -0
- data/rbi/temporalio/api/history/v1/message.rbi +40 -18
- data/rbi/temporalio/api/operatorservice/v1/request_response.rbi +480 -0
- data/rbi/temporalio/api/operatorservice/v1/service_services.rbi +32 -0
- data/rbi/temporalio/api/payload_visitor.rbi +33 -0
- data/rbi/temporalio/api/schedule/v1/message.rbi +12 -6
- data/rbi/temporalio/api/taskqueue/v1/message.rbi +179 -13
- data/rbi/temporalio/api/worker/v1/message.rbi +6 -6
- data/rbi/temporalio/api/workflow/v1/message.rbi +12 -6
- data/rbi/temporalio/api/workflowservice/v1/request_response.rbi +140 -41
- data/rbi/temporalio/api/workflowservice/v1/service_services.rbi +3 -0
- data/rbi/temporalio/client/connection/cloud_service.rbi +57 -0
- data/rbi/temporalio/client/connection/operator_service.rbi +9 -0
- data/rbi/temporalio/converters/data_converter.rbi +43 -2
- data/rbi/temporalio/converters/external_storage.rbi +2 -7
- data/rbi/temporalio/converters/storage_driver_limiter.rbi +4 -0
- data/rbi/temporalio/converters/storage_driver_retrieve_context.rbi +1 -1
- data/rbi/temporalio/converters/storage_driver_select_context.rbi +6 -2
- data/rbi/temporalio/converters/storage_driver_store_context.rbi +6 -2
- data/rbi/temporalio/error.rbi +3 -1
- data/rbi/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rbi +6 -0
- data/rbi/temporalio/internal/bridge/worker.rbi +4 -2
- data/rbi/temporalio/internal/client/described_schedule_action.rbi +22 -0
- data/rbi/temporalio/internal/client/implementation.rbi +30 -0
- data/rbi/temporalio/internal/external_storage_runner.rbi +36 -0
- data/rbi/temporalio/internal/storage_operation_metrics.rbi +27 -0
- data/rbi/temporalio/internal/worker/activity_worker.rbi +24 -4
- data/rbi/temporalio/internal/worker/workflow_worker.rbi +61 -1
- data/rbi/temporalio/workflow.rbi +0 -12
- data/sig/temporalio/api/cloud/account/v1/message.rbs +30 -0
- data/sig/temporalio/api/cloud/cloudservice/v1/request_response.rbs +2122 -601
- data/sig/temporalio/api/cloud/connectivityrule/v1/message.rbs +29 -4
- data/sig/temporalio/api/cloud/identity/v1/message.rbs +342 -1
- data/sig/temporalio/api/cloud/namespace/v1/message.rbs +341 -2
- data/sig/temporalio/api/cloud/nexus/v1/message.rbs +9 -0
- data/sig/temporalio/api/cloud/project/v1/message.rbs +164 -0
- data/sig/temporalio/api/cloud/region/v1/message.rbs +5 -3
- data/sig/temporalio/api/cloud/sink/v1/message.rbs +66 -0
- data/sig/temporalio/api/common/v1/message.rbs +6 -0
- data/sig/temporalio/api/enums/v1/event_type.rbs +1 -0
- data/sig/temporalio/api/enums/v1/failed_cause.rbs +9 -3
- data/sig/temporalio/api/enums/v1/namespace.rbs +30 -2
- data/sig/temporalio/api/enums/v1/time_skipping.rbs +1 -0
- data/sig/temporalio/api/history/v1/message.rbs +8 -0
- data/sig/temporalio/api/operatorservice/v1/request_response.rbs +188 -0
- data/sig/temporalio/api/payload_visitor.rbs +11 -0
- data/sig/temporalio/api/schedule/v1/message.rbs +2 -0
- data/sig/temporalio/api/taskqueue/v1/message.rbs +66 -5
- data/sig/temporalio/api/worker/v1/message.rbs +2 -2
- data/sig/temporalio/api/workflow/v1/message.rbs +2 -0
- data/sig/temporalio/api/workflowservice/v1/request_response.rbs +53 -9
- data/sig/temporalio/client/connection/cloud_service.rbs +76 -0
- data/sig/temporalio/client/connection/operator_service.rbs +12 -0
- data/sig/temporalio/client/schedule.rbs +24 -3
- data/sig/temporalio/contrib/aws/s3_driver/s3_storage_driver.rbs +2 -1
- data/sig/temporalio/contrib/open_telemetry.rbs +4 -4
- data/sig/temporalio/converters/data_converter.rbs +19 -1
- data/sig/temporalio/converters/external_storage.rbs +1 -3
- data/sig/temporalio/converters/storage_driver_limiter.rbs +5 -0
- data/sig/temporalio/converters/storage_driver_retrieve_context.rbs +1 -1
- data/sig/temporalio/converters/storage_driver_select_context.rbs +3 -1
- data/sig/temporalio/converters/storage_driver_store_context.rbs +3 -1
- data/sig/temporalio/error.rbs +4 -1
- data/sig/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rbs +4 -0
- data/sig/temporalio/internal/bridge/worker.rbs +2 -0
- data/sig/temporalio/internal/client/described_schedule_action.rbs +18 -0
- data/sig/temporalio/internal/client/implementation.rbs +22 -0
- data/sig/temporalio/internal/external_storage_runner.rbs +32 -0
- data/sig/temporalio/internal/storage_operation_metrics.rbs +25 -0
- data/sig/temporalio/internal/worker/activity_worker.rbs +11 -2
- data/sig/temporalio/internal/worker/workflow_worker.rbs +32 -1
- metadata +13 -2
- data/sig/open_telemetry.rbs +0 -47
|
@@ -19,6 +19,8 @@ require 'temporalio/client/workflow_execution_count'
|
|
|
19
19
|
require 'temporalio/client/workflow_handle'
|
|
20
20
|
require 'temporalio/common_enums'
|
|
21
21
|
require 'temporalio/converters'
|
|
22
|
+
require 'temporalio/converters/storage_driver_activity_info'
|
|
23
|
+
require 'temporalio/converters/storage_driver_workflow_info'
|
|
22
24
|
require 'temporalio/error'
|
|
23
25
|
require 'temporalio/error/failure'
|
|
24
26
|
require 'temporalio/internal/proto_utils'
|
|
@@ -80,13 +82,14 @@ module Temporalio
|
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
def start_workflow(input)
|
|
85
|
+
workflow_data_converter = _workflow_storage_data_converter(id: input.workflow_id, type: input.workflow)
|
|
83
86
|
req = Api::WorkflowService::V1::StartWorkflowExecutionRequest.new(
|
|
84
87
|
request_id: SecureRandom.uuid,
|
|
85
88
|
namespace: @client.namespace,
|
|
86
89
|
workflow_type: Api::Common::V1::WorkflowType.new(name: input.workflow),
|
|
87
90
|
workflow_id: input.workflow_id,
|
|
88
91
|
task_queue: Api::TaskQueue::V1::TaskQueue.new(name: input.task_queue.to_s),
|
|
89
|
-
input:
|
|
92
|
+
input: workflow_data_converter.to_payloads(input.args, hints: input.arg_hints),
|
|
90
93
|
workflow_execution_timeout: ProtoUtils.seconds_to_duration(input.execution_timeout),
|
|
91
94
|
workflow_run_timeout: ProtoUtils.seconds_to_duration(input.run_timeout),
|
|
92
95
|
workflow_task_timeout: ProtoUtils.seconds_to_duration(input.task_timeout),
|
|
@@ -95,14 +98,14 @@ module Temporalio
|
|
|
95
98
|
workflow_id_conflict_policy: input.id_conflict_policy,
|
|
96
99
|
retry_policy: input.retry_policy&._to_proto,
|
|
97
100
|
cron_schedule: input.cron_schedule,
|
|
98
|
-
memo: ProtoUtils.memo_to_proto(input.memo,
|
|
101
|
+
memo: ProtoUtils.memo_to_proto(input.memo, workflow_data_converter),
|
|
99
102
|
search_attributes: input.search_attributes&._to_proto,
|
|
100
103
|
workflow_start_delay: ProtoUtils.seconds_to_duration(input.start_delay),
|
|
101
104
|
request_eager_execution: input.request_eager_start,
|
|
102
105
|
user_metadata: ProtoUtils.to_user_metadata(
|
|
103
|
-
input.static_summary, input.static_details,
|
|
106
|
+
input.static_summary, input.static_details, workflow_data_converter
|
|
104
107
|
),
|
|
105
|
-
header: ProtoUtils.headers_to_proto(input.headers,
|
|
108
|
+
header: ProtoUtils.headers_to_proto(input.headers, workflow_data_converter),
|
|
106
109
|
priority: input.priority._to_proto,
|
|
107
110
|
versioning_override: input.versioning_override&._to_proto
|
|
108
111
|
)
|
|
@@ -156,6 +159,7 @@ module Temporalio
|
|
|
156
159
|
start_req = _start_workflow_request_from_with_start_options(
|
|
157
160
|
Api::WorkflowService::V1::StartWorkflowExecutionRequest, start_options
|
|
158
161
|
)
|
|
162
|
+
workflow_data_converter = _workflow_storage_data_converter(id: start_options.id, type: start_options.workflow)
|
|
159
163
|
req = Api::WorkflowService::V1::ExecuteMultiOperationRequest.new(
|
|
160
164
|
namespace: @client.namespace,
|
|
161
165
|
operations: [
|
|
@@ -173,8 +177,8 @@ module Temporalio
|
|
|
173
177
|
),
|
|
174
178
|
input: Api::Update::V1::Input.new(
|
|
175
179
|
name: input.update,
|
|
176
|
-
args:
|
|
177
|
-
header: Internal::ProtoUtils.headers_to_proto(input.headers,
|
|
180
|
+
args: workflow_data_converter.to_payloads(input.args, hints: input.arg_hints),
|
|
181
|
+
header: Internal::ProtoUtils.headers_to_proto(input.headers, workflow_data_converter)
|
|
178
182
|
)
|
|
179
183
|
),
|
|
180
184
|
wait_policy: Api::Update::V1::WaitPolicy.new(
|
|
@@ -297,7 +301,8 @@ module Temporalio
|
|
|
297
301
|
Api::WorkflowService::V1::SignalWithStartWorkflowExecutionRequest, start_options
|
|
298
302
|
)
|
|
299
303
|
req.signal_name = input.signal
|
|
300
|
-
|
|
304
|
+
workflow_data_converter = _workflow_storage_data_converter(id: start_options.id, type: start_options.workflow)
|
|
305
|
+
req.signal_input = workflow_data_converter.to_payloads(input.args, hints: input.arg_hints)
|
|
301
306
|
|
|
302
307
|
# Send request
|
|
303
308
|
begin
|
|
@@ -338,13 +343,14 @@ module Temporalio
|
|
|
338
343
|
end
|
|
339
344
|
|
|
340
345
|
def _start_workflow_request_from_with_start_options(klass, start_options)
|
|
346
|
+
workflow_data_converter = _workflow_storage_data_converter(id: start_options.id, type: start_options.workflow)
|
|
341
347
|
klass.new(
|
|
342
348
|
request_id: SecureRandom.uuid,
|
|
343
349
|
namespace: @client.namespace,
|
|
344
350
|
workflow_type: Api::Common::V1::WorkflowType.new(name: start_options.workflow),
|
|
345
351
|
workflow_id: start_options.id,
|
|
346
352
|
task_queue: Api::TaskQueue::V1::TaskQueue.new(name: start_options.task_queue.to_s),
|
|
347
|
-
input:
|
|
353
|
+
input: workflow_data_converter.to_payloads(start_options.args, hints: start_options.arg_hints),
|
|
348
354
|
workflow_execution_timeout: ProtoUtils.seconds_to_duration(start_options.execution_timeout),
|
|
349
355
|
workflow_run_timeout: ProtoUtils.seconds_to_duration(start_options.run_timeout),
|
|
350
356
|
workflow_task_timeout: ProtoUtils.seconds_to_duration(start_options.task_timeout),
|
|
@@ -353,17 +359,47 @@ module Temporalio
|
|
|
353
359
|
workflow_id_conflict_policy: start_options.id_conflict_policy,
|
|
354
360
|
retry_policy: start_options.retry_policy&._to_proto,
|
|
355
361
|
cron_schedule: start_options.cron_schedule,
|
|
356
|
-
memo: ProtoUtils.memo_to_proto(start_options.memo,
|
|
362
|
+
memo: ProtoUtils.memo_to_proto(start_options.memo, workflow_data_converter),
|
|
357
363
|
search_attributes: start_options.search_attributes&._to_proto,
|
|
358
364
|
workflow_start_delay: ProtoUtils.seconds_to_duration(start_options.start_delay),
|
|
359
365
|
user_metadata: ProtoUtils.to_user_metadata(
|
|
360
|
-
start_options.static_summary, start_options.static_details,
|
|
366
|
+
start_options.static_summary, start_options.static_details, workflow_data_converter
|
|
361
367
|
),
|
|
362
|
-
header: ProtoUtils.headers_to_proto(start_options.headers,
|
|
368
|
+
header: ProtoUtils.headers_to_proto(start_options.headers, workflow_data_converter),
|
|
363
369
|
priority: start_options.priority._to_proto
|
|
364
370
|
)
|
|
365
371
|
end
|
|
366
372
|
|
|
373
|
+
def _storage_data_converter(target)
|
|
374
|
+
@client.data_converter._with_storage_target(namespace: @client.namespace, target:)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def _workflow_storage_data_converter(id:, run_id: nil, type: nil)
|
|
378
|
+
_storage_data_converter(
|
|
379
|
+
Converters::StorageDriverWorkflowInfo.new(namespace: @client.namespace, id:, run_id:, type:)
|
|
380
|
+
)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def _activity_storage_data_converter(id:, run_id: nil, type: nil)
|
|
384
|
+
_storage_data_converter(
|
|
385
|
+
Converters::StorageDriverActivityInfo.new(namespace: @client.namespace, id:, run_id:, type:)
|
|
386
|
+
)
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def _async_activity_storage_data_converter(ref)
|
|
390
|
+
return _storage_data_converter(nil) unless ref.is_a?(Temporalio::Client::ActivityIDReference)
|
|
391
|
+
return _activity_storage_data_converter(id: ref.activity_id, run_id: ref.activity_run_id) if ref.standalone?
|
|
392
|
+
|
|
393
|
+
_workflow_storage_data_converter(id: ref.workflow_id, run_id: ref.run_id)
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def _schedule_memo_storage_data_converter(action)
|
|
397
|
+
return _storage_data_converter(nil) unless action.is_a?(Temporalio::Client::Schedule::Action::StartWorkflow)
|
|
398
|
+
|
|
399
|
+
workflow_type = action.workflow #: String
|
|
400
|
+
_workflow_storage_data_converter(id: action.id, type: workflow_type)
|
|
401
|
+
end
|
|
402
|
+
|
|
367
403
|
def list_workflow_page(input)
|
|
368
404
|
req = Api::WorkflowService::V1::ListWorkflowExecutionsRequest.new(
|
|
369
405
|
namespace: @client.namespace,
|
|
@@ -443,6 +479,7 @@ module Temporalio
|
|
|
443
479
|
end
|
|
444
480
|
|
|
445
481
|
def signal_workflow(input)
|
|
482
|
+
workflow_data_converter = _workflow_storage_data_converter(id: input.workflow_id, run_id: input.run_id)
|
|
446
483
|
@client.workflow_service.signal_workflow_execution(
|
|
447
484
|
Api::WorkflowService::V1::SignalWorkflowExecutionRequest.new(
|
|
448
485
|
namespace: @client.namespace,
|
|
@@ -451,8 +488,8 @@ module Temporalio
|
|
|
451
488
|
run_id: input.run_id || ''
|
|
452
489
|
),
|
|
453
490
|
signal_name: input.signal,
|
|
454
|
-
input:
|
|
455
|
-
header: Internal::ProtoUtils.headers_to_proto(input.headers,
|
|
491
|
+
input: workflow_data_converter.to_payloads(input.args, hints: input.arg_hints),
|
|
492
|
+
header: Internal::ProtoUtils.headers_to_proto(input.headers, workflow_data_converter),
|
|
456
493
|
identity: @client.connection.identity,
|
|
457
494
|
request_id: SecureRandom.uuid
|
|
458
495
|
),
|
|
@@ -462,6 +499,7 @@ module Temporalio
|
|
|
462
499
|
end
|
|
463
500
|
|
|
464
501
|
def query_workflow(input)
|
|
502
|
+
workflow_data_converter = _workflow_storage_data_converter(id: input.workflow_id, run_id: input.run_id)
|
|
465
503
|
begin
|
|
466
504
|
resp = @client.workflow_service.query_workflow(
|
|
467
505
|
Api::WorkflowService::V1::QueryWorkflowRequest.new(
|
|
@@ -472,8 +510,8 @@ module Temporalio
|
|
|
472
510
|
),
|
|
473
511
|
query: Api::Query::V1::WorkflowQuery.new(
|
|
474
512
|
query_type: input.query,
|
|
475
|
-
query_args:
|
|
476
|
-
header: Internal::ProtoUtils.headers_to_proto(input.headers,
|
|
513
|
+
query_args: workflow_data_converter.to_payloads(input.args, hints: input.arg_hints),
|
|
514
|
+
header: Internal::ProtoUtils.headers_to_proto(input.headers, workflow_data_converter)
|
|
477
515
|
),
|
|
478
516
|
query_reject_condition: input.reject_condition || 0
|
|
479
517
|
),
|
|
@@ -502,6 +540,7 @@ module Temporalio
|
|
|
502
540
|
raise ArgumentError, 'ADMITTED wait stage not supported'
|
|
503
541
|
end
|
|
504
542
|
|
|
543
|
+
workflow_data_converter = _workflow_storage_data_converter(id: input.workflow_id, run_id: input.run_id)
|
|
505
544
|
req = Api::WorkflowService::V1::UpdateWorkflowExecutionRequest.new(
|
|
506
545
|
namespace: @client.namespace,
|
|
507
546
|
workflow_execution: Api::Common::V1::WorkflowExecution.new(
|
|
@@ -515,8 +554,8 @@ module Temporalio
|
|
|
515
554
|
),
|
|
516
555
|
input: Api::Update::V1::Input.new(
|
|
517
556
|
name: input.update,
|
|
518
|
-
args:
|
|
519
|
-
header: Internal::ProtoUtils.headers_to_proto(input.headers,
|
|
557
|
+
args: workflow_data_converter.to_payloads(input.args, hints: input.arg_hints),
|
|
558
|
+
header: Internal::ProtoUtils.headers_to_proto(input.headers, workflow_data_converter)
|
|
520
559
|
)
|
|
521
560
|
),
|
|
522
561
|
wait_policy: Api::Update::V1::WaitPolicy.new(
|
|
@@ -628,6 +667,7 @@ module Temporalio
|
|
|
628
667
|
end
|
|
629
668
|
|
|
630
669
|
def terminate_workflow(input)
|
|
670
|
+
workflow_data_converter = _workflow_storage_data_converter(id: input.workflow_id, run_id: input.run_id)
|
|
631
671
|
@client.workflow_service.terminate_workflow_execution(
|
|
632
672
|
Api::WorkflowService::V1::TerminateWorkflowExecutionRequest.new(
|
|
633
673
|
namespace: @client.namespace,
|
|
@@ -637,7 +677,7 @@ module Temporalio
|
|
|
637
677
|
),
|
|
638
678
|
reason: input.reason || '',
|
|
639
679
|
first_execution_run_id: input.first_execution_run_id,
|
|
640
|
-
details:
|
|
680
|
+
details: workflow_data_converter.to_payloads(input.details),
|
|
641
681
|
identity: @client.connection.identity
|
|
642
682
|
),
|
|
643
683
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
@@ -657,7 +697,7 @@ module Temporalio
|
|
|
657
697
|
Api::WorkflowService::V1::CreateScheduleRequest.new(
|
|
658
698
|
namespace: @client.namespace,
|
|
659
699
|
schedule_id: input.id,
|
|
660
|
-
schedule: input.schedule._to_proto(@client.data_converter),
|
|
700
|
+
schedule: input.schedule._to_proto(@client.data_converter, @client.namespace),
|
|
661
701
|
initial_patch: if input.trigger_immediately || !input.backfills.empty?
|
|
662
702
|
Api::Schedule::V1::SchedulePatch.new(
|
|
663
703
|
trigger_immediately: if input.trigger_immediately
|
|
@@ -670,7 +710,7 @@ module Temporalio
|
|
|
670
710
|
end,
|
|
671
711
|
identity: @client.connection.identity,
|
|
672
712
|
request_id: SecureRandom.uuid,
|
|
673
|
-
memo: ProtoUtils.memo_to_proto(input.memo,
|
|
713
|
+
memo: ProtoUtils.memo_to_proto(input.memo, _schedule_memo_storage_data_converter(input.schedule.action)),
|
|
674
714
|
search_attributes: input.search_attributes&._to_proto
|
|
675
715
|
),
|
|
676
716
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
@@ -802,21 +842,20 @@ module Temporalio
|
|
|
802
842
|
# TODO(cretz): This is supposed to be a retry-conflict loop, but we do
|
|
803
843
|
# not yet have a way to know update failure is due to conflict token
|
|
804
844
|
# mismatch
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
),
|
|
816
|
-
data_converter: @client.data_converter
|
|
817
|
-
)
|
|
818
|
-
)
|
|
845
|
+
description = Temporalio::Client::Schedule::Description.new(
|
|
846
|
+
id: input.id,
|
|
847
|
+
raw_description: @client.workflow_service.describe_schedule(
|
|
848
|
+
Api::WorkflowService::V1::DescribeScheduleRequest.new(
|
|
849
|
+
namespace: @client.namespace,
|
|
850
|
+
schedule_id: input.id
|
|
851
|
+
),
|
|
852
|
+
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
853
|
+
),
|
|
854
|
+
data_converter: @client.data_converter
|
|
819
855
|
)
|
|
856
|
+
# Captured before the updater runs, since it may change the described action in place.
|
|
857
|
+
described_action = description.schedule.action._described(description.raw_description.schedule.action)
|
|
858
|
+
update = input.updater.call(Temporalio::Client::Schedule::Update::Input.new(description:))
|
|
820
859
|
# Do nothing if update is nil, fail if not an expected update
|
|
821
860
|
return nil if update.nil?
|
|
822
861
|
|
|
@@ -829,7 +868,7 @@ module Temporalio
|
|
|
829
868
|
Api::WorkflowService::V1::UpdateScheduleRequest.new(
|
|
830
869
|
namespace: @client.namespace,
|
|
831
870
|
schedule_id: input.id,
|
|
832
|
-
schedule: update.schedule._to_proto(@client.data_converter),
|
|
871
|
+
schedule: update.schedule._to_proto(@client.data_converter, @client.namespace, described_action),
|
|
833
872
|
search_attributes: update.search_attributes&._to_proto,
|
|
834
873
|
identity: @client.connection.identity,
|
|
835
874
|
request_id: SecureRandom.uuid
|
|
@@ -841,13 +880,14 @@ module Temporalio
|
|
|
841
880
|
|
|
842
881
|
def heartbeat_async_activity(input)
|
|
843
882
|
ref = input.task_token_or_id_reference
|
|
883
|
+
async_activity_data_converter = _async_activity_storage_data_converter(ref)
|
|
844
884
|
resp = if ref.is_a?(Temporalio::Client::ActivityIDReference)
|
|
845
885
|
@client.workflow_service.record_activity_task_heartbeat_by_id(
|
|
846
886
|
Api::WorkflowService::V1::RecordActivityTaskHeartbeatByIdRequest.new(
|
|
847
887
|
**Implementation._activity_id_reference_request_fields(ref),
|
|
848
888
|
namespace: @client.namespace,
|
|
849
889
|
identity: @client.connection.identity,
|
|
850
|
-
details:
|
|
890
|
+
details: async_activity_data_converter.to_payloads(input.details, hints: input.detail_hints)
|
|
851
891
|
),
|
|
852
892
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
853
893
|
)
|
|
@@ -857,7 +897,7 @@ module Temporalio
|
|
|
857
897
|
task_token: ref,
|
|
858
898
|
namespace: @client.namespace,
|
|
859
899
|
identity: @client.connection.identity,
|
|
860
|
-
details:
|
|
900
|
+
details: async_activity_data_converter.to_payloads(input.details, hints: input.detail_hints)
|
|
861
901
|
),
|
|
862
902
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
863
903
|
)
|
|
@@ -873,13 +913,14 @@ module Temporalio
|
|
|
873
913
|
|
|
874
914
|
def complete_async_activity(input)
|
|
875
915
|
ref = input.task_token_or_id_reference
|
|
916
|
+
async_activity_data_converter = _async_activity_storage_data_converter(ref)
|
|
876
917
|
if ref.is_a?(Temporalio::Client::ActivityIDReference)
|
|
877
918
|
@client.workflow_service.respond_activity_task_completed_by_id(
|
|
878
919
|
Api::WorkflowService::V1::RespondActivityTaskCompletedByIdRequest.new(
|
|
879
920
|
**Implementation._activity_id_reference_request_fields(ref),
|
|
880
921
|
namespace: @client.namespace,
|
|
881
922
|
identity: @client.connection.identity,
|
|
882
|
-
result:
|
|
923
|
+
result: async_activity_data_converter.to_payloads([input.result], hints: Array(input.result_hint))
|
|
883
924
|
),
|
|
884
925
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
885
926
|
)
|
|
@@ -889,7 +930,7 @@ module Temporalio
|
|
|
889
930
|
task_token: ref,
|
|
890
931
|
namespace: @client.namespace,
|
|
891
932
|
identity: @client.connection.identity,
|
|
892
|
-
result:
|
|
933
|
+
result: async_activity_data_converter.to_payloads([input.result], hints: Array(input.result_hint))
|
|
893
934
|
),
|
|
894
935
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
895
936
|
)
|
|
@@ -898,22 +939,23 @@ module Temporalio
|
|
|
898
939
|
end
|
|
899
940
|
|
|
900
941
|
def fail_async_activity(input)
|
|
942
|
+
ref = input.task_token_or_id_reference
|
|
943
|
+
async_activity_data_converter = _async_activity_storage_data_converter(ref)
|
|
901
944
|
last_heartbeat_details = if input.last_heartbeat_details.empty?
|
|
902
945
|
nil
|
|
903
946
|
else
|
|
904
|
-
|
|
947
|
+
async_activity_data_converter.to_payloads(
|
|
905
948
|
input.last_heartbeat_details,
|
|
906
949
|
hints: input.last_heartbeat_detail_hints
|
|
907
950
|
)
|
|
908
951
|
end
|
|
909
|
-
ref = input.task_token_or_id_reference
|
|
910
952
|
if ref.is_a?(Temporalio::Client::ActivityIDReference)
|
|
911
953
|
@client.workflow_service.respond_activity_task_failed_by_id(
|
|
912
954
|
Api::WorkflowService::V1::RespondActivityTaskFailedByIdRequest.new(
|
|
913
955
|
**Implementation._activity_id_reference_request_fields(ref),
|
|
914
956
|
namespace: @client.namespace,
|
|
915
957
|
identity: @client.connection.identity,
|
|
916
|
-
failure:
|
|
958
|
+
failure: async_activity_data_converter.to_failure(input.error),
|
|
917
959
|
last_heartbeat_details:
|
|
918
960
|
),
|
|
919
961
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
@@ -924,7 +966,7 @@ module Temporalio
|
|
|
924
966
|
task_token: ref,
|
|
925
967
|
namespace: @client.namespace,
|
|
926
968
|
identity: @client.connection.identity,
|
|
927
|
-
failure:
|
|
969
|
+
failure: async_activity_data_converter.to_failure(input.error),
|
|
928
970
|
last_heartbeat_details:
|
|
929
971
|
),
|
|
930
972
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
@@ -935,13 +977,14 @@ module Temporalio
|
|
|
935
977
|
|
|
936
978
|
def report_cancellation_async_activity(input)
|
|
937
979
|
ref = input.task_token_or_id_reference
|
|
980
|
+
async_activity_data_converter = _async_activity_storage_data_converter(ref)
|
|
938
981
|
if ref.is_a?(Temporalio::Client::ActivityIDReference)
|
|
939
982
|
@client.workflow_service.respond_activity_task_canceled_by_id(
|
|
940
983
|
Api::WorkflowService::V1::RespondActivityTaskCanceledByIdRequest.new(
|
|
941
984
|
**Implementation._activity_id_reference_request_fields(ref),
|
|
942
985
|
namespace: @client.namespace,
|
|
943
986
|
identity: @client.connection.identity,
|
|
944
|
-
details:
|
|
987
|
+
details: async_activity_data_converter.to_payloads(input.details, hints: input.detail_hints)
|
|
945
988
|
),
|
|
946
989
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
947
990
|
)
|
|
@@ -951,7 +994,7 @@ module Temporalio
|
|
|
951
994
|
task_token: ref,
|
|
952
995
|
namespace: @client.namespace,
|
|
953
996
|
identity: @client.connection.identity,
|
|
954
|
-
details:
|
|
997
|
+
details: async_activity_data_converter.to_payloads(input.details, hints: input.detail_hints)
|
|
955
998
|
),
|
|
956
999
|
rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
|
|
957
1000
|
)
|
|
@@ -967,6 +1010,7 @@ module Temporalio
|
|
|
967
1010
|
end
|
|
968
1011
|
raise ArgumentError, 'start_delay must be non-negative' if input.start_delay&.negative?
|
|
969
1012
|
|
|
1013
|
+
activity_data_converter = _activity_storage_data_converter(id: input.activity_id, type: input.activity)
|
|
970
1014
|
req = Api::WorkflowService::V1::StartActivityExecutionRequest.new(
|
|
971
1015
|
namespace: @client.namespace,
|
|
972
1016
|
identity: @client.connection.identity,
|
|
@@ -974,7 +1018,7 @@ module Temporalio
|
|
|
974
1018
|
activity_id: input.activity_id,
|
|
975
1019
|
activity_type: Api::Common::V1::ActivityType.new(name: input.activity),
|
|
976
1020
|
task_queue: Api::TaskQueue::V1::TaskQueue.new(name: input.task_queue.to_s),
|
|
977
|
-
input:
|
|
1021
|
+
input: activity_data_converter.to_payloads(input.args, hints: input.arg_hints),
|
|
978
1022
|
schedule_to_close_timeout: ProtoUtils.seconds_to_duration(input.schedule_to_close_timeout),
|
|
979
1023
|
schedule_to_start_timeout: ProtoUtils.seconds_to_duration(input.schedule_to_start_timeout),
|
|
980
1024
|
start_to_close_timeout: ProtoUtils.seconds_to_duration(input.start_to_close_timeout),
|
|
@@ -984,9 +1028,9 @@ module Temporalio
|
|
|
984
1028
|
retry_policy: input.retry_policy&._to_proto,
|
|
985
1029
|
search_attributes: input.search_attributes&._to_proto,
|
|
986
1030
|
user_metadata: ProtoUtils.to_user_metadata(
|
|
987
|
-
input.summary, input.static_details,
|
|
1031
|
+
input.summary, input.static_details, activity_data_converter
|
|
988
1032
|
),
|
|
989
|
-
header: ProtoUtils.headers_to_proto(input.headers,
|
|
1033
|
+
header: ProtoUtils.headers_to_proto(input.headers, activity_data_converter),
|
|
990
1034
|
priority: input.priority._to_proto,
|
|
991
1035
|
start_delay: ProtoUtils.seconds_to_duration(input.start_delay)
|
|
992
1036
|
)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'temporalio/api'
|
|
4
4
|
require 'temporalio/api/sdk/v1/external_storage'
|
|
5
|
+
require 'temporalio/error'
|
|
5
6
|
|
|
6
7
|
module Temporalio
|
|
7
8
|
module Internal
|
|
@@ -24,10 +25,7 @@ module Temporalio
|
|
|
24
25
|
|
|
25
26
|
# @param payload [Api::Common::V1::Payload] Payload to parse.
|
|
26
27
|
# @return [Api::Sdk::V1::ExternalStorageReference, nil] Parsed reference, or nil if not a reference.
|
|
27
|
-
#
|
|
28
|
-
# TODO: Surface parse failures as a Temporal error instead of Google::Protobuf::ParseError. The runner is the
|
|
29
|
-
# right layer for it, since only the caller knows which payload failed; a malformed reference cannot name its
|
|
30
|
-
# own driver.
|
|
28
|
+
# @raise [Error::ExternalStorageError] If the payload is a reference but cannot be read as one.
|
|
31
29
|
def parse_reference(payload)
|
|
32
30
|
return nil unless reference?(payload)
|
|
33
31
|
|
|
@@ -36,6 +34,9 @@ module Temporalio
|
|
|
36
34
|
Api::Sdk::V1::ExternalStorageReference.decode_json(
|
|
37
35
|
payload.data, ignore_unknown_fields: true
|
|
38
36
|
)
|
|
37
|
+
rescue Google::Protobuf::ParseError => e
|
|
38
|
+
raise Error::ExternalStorageError,
|
|
39
|
+
"Payload is marked as an external storage reference but could not be read as one: #{e.message}"
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
# @param driver_name [String] Name of the driver that stored the payload.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'temporalio/api'
|
|
4
|
+
require 'temporalio/cancellation'
|
|
5
|
+
require 'temporalio/converters/storage_driver_claim'
|
|
6
|
+
require 'temporalio/converters/storage_driver_retrieve_context'
|
|
7
|
+
require 'temporalio/converters/storage_driver_select_context'
|
|
8
|
+
require 'temporalio/converters/storage_driver_store_context'
|
|
9
|
+
require 'temporalio/error'
|
|
10
|
+
require 'temporalio/internal/external_storage_references'
|
|
11
|
+
require 'temporalio/internal/storage_operation_metrics'
|
|
12
|
+
|
|
13
|
+
module Temporalio
|
|
14
|
+
module Internal
|
|
15
|
+
# Stores large payloads in external storage and fetches them back.
|
|
16
|
+
#
|
|
17
|
+
# Storing replaces each payload at or above the size threshold with a reference to what a driver stored. Retrieving
|
|
18
|
+
# swaps references back for the payloads they point at. Payloads are expected to already be codec-encoded when
|
|
19
|
+
# stored, and are returned still encoded when retrieved.
|
|
20
|
+
#
|
|
21
|
+
# Each driver gets one batched request per call, and requests to different drivers run one after another.
|
|
22
|
+
# Concurrency limits are not enforced. Drivers get the contexts' default limiter, which grants every permit.
|
|
23
|
+
#
|
|
24
|
+
# @!visibility private
|
|
25
|
+
class ExternalStorageRunner
|
|
26
|
+
MONOTONIC_CLOCK = -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }
|
|
27
|
+
private_constant :MONOTONIC_CLOCK
|
|
28
|
+
|
|
29
|
+
# @param storage [Converters::ExternalStorage, nil] Configured storage. When nil, storing does nothing and
|
|
30
|
+
# retrieving raises if it finds a reference, so a reference is never mistaken for an ordinary payload.
|
|
31
|
+
# @param namespace [String, nil] Namespace of the client or worker storing through this runner, or nil when it is
|
|
32
|
+
# not known.
|
|
33
|
+
# @param clock [Proc] Returns monotonic seconds, read around each driver call to time it.
|
|
34
|
+
def initialize(storage, namespace:, clock: MONOTONIC_CLOCK)
|
|
35
|
+
@storage = storage
|
|
36
|
+
@namespace = namespace
|
|
37
|
+
@clock = clock
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param payloads [Array<Api::Common::V1::Payload>] Codec-encoded payloads. Not mutated.
|
|
41
|
+
# @param target [Converters::StorageDriverWorkflowInfo, Converters::StorageDriverActivityInfo, nil] The
|
|
42
|
+
# execution every one of these payloads is stored on behalf of, or nil when there is none.
|
|
43
|
+
# @param metrics [StorageOperationMetrics, nil] Records each driver call that stores payloads.
|
|
44
|
+
# @return [Array<Api::Common::V1::Payload>] Payloads with every eligible one replaced by a reference.
|
|
45
|
+
def store(payloads, target: nil, metrics: nil)
|
|
46
|
+
storage = @storage
|
|
47
|
+
return payloads unless storage
|
|
48
|
+
|
|
49
|
+
select_context = Converters::StorageDriverSelectContext.new(
|
|
50
|
+
target:, cancellation: Cancellation.new, namespace: @namespace
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Driver => [[index, serialized payload], ...] for each payload that driver stores
|
|
54
|
+
payloads_by_driver = Hash.new { |hash, driver| hash[driver] = [] }
|
|
55
|
+
payloads.each_with_index do |payload, index|
|
|
56
|
+
serialized = payload.to_proto
|
|
57
|
+
next if serialized.bytesize < storage.payload_size_threshold
|
|
58
|
+
|
|
59
|
+
driver = raise_as_storage_error('External storage driver selector failed') do
|
|
60
|
+
storage.driver_selector.call(select_context, payload)
|
|
61
|
+
end
|
|
62
|
+
next unless driver
|
|
63
|
+
|
|
64
|
+
# Checked by identity, so a driver built to look like a registered one is rejected.
|
|
65
|
+
unless storage.driver(driver.name).equal?(driver)
|
|
66
|
+
raise Error::ExternalStorageError,
|
|
67
|
+
"External storage driver selector returned a driver that is not registered: #{driver.inspect}"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
payloads_by_driver[driver] << [index, serialized]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
result = payloads.dup
|
|
74
|
+
payloads_by_driver.each do |driver, indexes_and_serialized|
|
|
75
|
+
context = Converters::StorageDriverStoreContext.new(
|
|
76
|
+
target:, cancellation: Cancellation.new, namespace: @namespace
|
|
77
|
+
)
|
|
78
|
+
# Drivers get copies, since a driver may keep a payload after returning and the SDK modifies some payloads in
|
|
79
|
+
# place
|
|
80
|
+
copies = indexes_and_serialized.map { |_index, serialized| Api::Common::V1::Payload.decode(serialized) }
|
|
81
|
+
start_time = @clock.call
|
|
82
|
+
claims = raise_as_storage_error("External storage driver '#{driver.name}' failed to store payloads") do
|
|
83
|
+
driver.store(context, copies)
|
|
84
|
+
end
|
|
85
|
+
end_time = @clock.call
|
|
86
|
+
check_driver_result(driver, 'store', indexes_and_serialized.size, claims, Converters::StorageDriverClaim)
|
|
87
|
+
metrics&.record(
|
|
88
|
+
driver_name: driver.name,
|
|
89
|
+
payload_count: claims.size,
|
|
90
|
+
total_size_bytes: indexes_and_serialized.sum { |_index, serialized| serialized.bytesize },
|
|
91
|
+
start_time:,
|
|
92
|
+
end_time:
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
indexes_and_serialized.zip(claims) do |(index, serialized), claim|
|
|
96
|
+
result[index] = ExternalStorageReferences.create_reference_payload(
|
|
97
|
+
driver_name: driver.name, claim_data: claim.claim_data, original_size_bytes: serialized.bytesize
|
|
98
|
+
)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
result
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @param payloads [Array<Api::Common::V1::Payload>] Payloads that may contain references. Not mutated.
|
|
105
|
+
# @param metrics [StorageOperationMetrics, nil] Records each driver call that retrieves payloads.
|
|
106
|
+
# @return [Array<Api::Common::V1::Payload>] Payloads with every reference replaced by what it points at.
|
|
107
|
+
# @raise [Error::ExternalStorageNotConfiguredError] If there is a reference but no storage is configured.
|
|
108
|
+
# @raise [Error::ExternalStorageError] If a reference cannot be read or retrieved.
|
|
109
|
+
def retrieve(payloads, metrics: nil)
|
|
110
|
+
storage = @storage
|
|
111
|
+
# Driver => [[index, claim], ...] for each reference that driver stored. Every driver is looked up here, so an
|
|
112
|
+
# unregistered name fails before any request is made.
|
|
113
|
+
claims_by_driver = Hash.new { |hash, driver| hash[driver] = [] }
|
|
114
|
+
payloads.each_with_index do |payload, index|
|
|
115
|
+
reference = ExternalStorageReferences.parse_reference(payload)
|
|
116
|
+
next unless reference
|
|
117
|
+
raise Error::ExternalStorageNotConfiguredError unless storage
|
|
118
|
+
|
|
119
|
+
driver = storage.driver(reference.driver_name)
|
|
120
|
+
unless driver
|
|
121
|
+
raise Error::ExternalStorageError,
|
|
122
|
+
"No external storage driver registered with name '#{reference.driver_name}'"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
claims_by_driver[driver] << [index, Converters::StorageDriverClaim.new(claim_data: reference.claim_data.to_h)]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
result = payloads.dup
|
|
129
|
+
claims_by_driver.each do |driver, indexes_and_claims|
|
|
130
|
+
context = Converters::StorageDriverRetrieveContext.new(cancellation: Cancellation.new)
|
|
131
|
+
start_time = @clock.call
|
|
132
|
+
retrieved = raise_as_storage_error("External storage driver '#{driver.name}' failed to retrieve payloads") do
|
|
133
|
+
driver.retrieve(context, indexes_and_claims.map { |_index, claim| claim })
|
|
134
|
+
end
|
|
135
|
+
end_time = @clock.call
|
|
136
|
+
check_driver_result(driver, 'retrieve', indexes_and_claims.size, retrieved, Api::Common::V1::Payload)
|
|
137
|
+
metrics&.record(
|
|
138
|
+
driver_name: driver.name,
|
|
139
|
+
payload_count: retrieved.size,
|
|
140
|
+
total_size_bytes: retrieved.sum { |payload| payload.to_proto.bytesize },
|
|
141
|
+
start_time:,
|
|
142
|
+
end_time:
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
indexes_and_claims.zip(retrieved) { |(index, _claim), payload| result[index] = payload }
|
|
146
|
+
end
|
|
147
|
+
result
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
private
|
|
151
|
+
|
|
152
|
+
def raise_as_storage_error(failure_message)
|
|
153
|
+
yield
|
|
154
|
+
rescue Error::ExternalStorageError, Error::CanceledError
|
|
155
|
+
raise
|
|
156
|
+
rescue StandardError => e
|
|
157
|
+
raise Error::ExternalStorageError, "#{failure_message}: #{e.message}"
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def check_driver_result(driver, operation, requested, returned, expected_item_class)
|
|
161
|
+
unless returned.is_a?(Array) && returned.size == requested
|
|
162
|
+
raise Error::ExternalStorageError,
|
|
163
|
+
"External storage driver '#{driver.name}' #{operation} was given #{requested} item(s) but " \
|
|
164
|
+
"returned #{returned.is_a?(Array) ? returned.size : returned.inspect}"
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
returned.each do |item|
|
|
168
|
+
next if item.is_a?(expected_item_class)
|
|
169
|
+
|
|
170
|
+
raise Error::ExternalStorageError,
|
|
171
|
+
"External storage driver '#{driver.name}' #{operation} returned #{item.inspect} instead of a " \
|
|
172
|
+
"#{expected_item_class}"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|