temporalio 0.0.1 → 0.0.2
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/README.md +175 -4
- data/bridge/Cargo.lock +44 -21
- data/bridge/Cargo.toml +1 -0
- data/bridge/sdk-core/Cargo.toml +1 -1
- data/bridge/sdk-core/README.md +1 -4
- data/bridge/sdk-core/client/Cargo.toml +1 -1
- data/bridge/sdk-core/client/src/lib.rs +12 -20
- data/bridge/sdk-core/client/src/raw.rs +9 -8
- data/bridge/sdk-core/client/src/retry.rs +100 -23
- data/bridge/sdk-core/core/Cargo.toml +7 -7
- data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
- data/bridge/sdk-core/core/src/abstractions.rs +22 -22
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +146 -43
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +419 -9
- data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -89
- data/bridge/sdk-core/core/src/core_tests/workers.rs +2 -2
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +47 -27
- data/bridge/sdk-core/core/src/lib.rs +139 -32
- data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
- data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +184 -139
- data/bridge/sdk-core/core/src/telemetry/mod.rs +310 -315
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +4 -3
- data/bridge/sdk-core/core/src/test_help/mod.rs +23 -9
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +12 -6
- data/bridge/sdk-core/core/src/worker/activities.rs +40 -23
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +1 -1
- data/bridge/sdk-core/core/src/worker/client.rs +30 -4
- data/bridge/sdk-core/core/src/worker/mod.rs +23 -19
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +10 -19
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +99 -25
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +3 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +2 -6
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +24 -22
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +12 -38
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +8 -2
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +233 -217
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +1 -6
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +4 -4
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +13 -5
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +86 -29
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +56 -11
- data/bridge/sdk-core/core-api/Cargo.toml +4 -3
- data/bridge/sdk-core/core-api/src/lib.rs +1 -43
- data/bridge/sdk-core/core-api/src/telemetry.rs +147 -0
- data/bridge/sdk-core/core-api/src/worker.rs +13 -0
- data/bridge/sdk-core/etc/deps.svg +115 -140
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -3
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
- data/bridge/sdk-core/protos/api_upstream/{temporal/api/update/v1/message.proto → build/tools.go} +6 -23
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +20 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +5 -3
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +23 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/{cluster.proto → interaction_type.proto} +10 -11
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +2 -13
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +26 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +21 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -16
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +17 -3
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +8 -1
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- data/bridge/sdk-core/sdk/Cargo.toml +2 -2
- data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
- data/bridge/sdk-core/sdk/src/lib.rs +7 -5
- data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
- data/bridge/sdk-core/sdk/src/workflow_future.rs +3 -7
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +1 -1
- data/bridge/sdk-core/sdk-core-protos/build.rs +0 -1
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +65 -18
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +22 -22
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +104 -44
- data/bridge/sdk-core/test-utils/Cargo.toml +2 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +81 -29
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -2
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +167 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +106 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +18 -8
- data/bridge/sdk-core/tests/main.rs +6 -4
- data/bridge/src/connection.rs +81 -62
- data/bridge/src/lib.rs +92 -33
- data/bridge/src/runtime.rs +9 -2
- data/bridge/src/worker.rs +53 -2
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
- data/lib/gen/temporal/api/command/v1/message_pb.rb +17 -9
- data/lib/gen/temporal/api/common/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -1
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +3 -2
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +7 -1
- data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +25 -0
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +1 -6
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/history/v1/message_pb.rb +19 -18
- data/lib/gen/temporal/api/interaction/v1/message_pb.rb +49 -0
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +11 -51
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
- data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +27 -10
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +1 -0
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +5 -1
- data/lib/temporalio/activity/context.rb +97 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/{temporal → temporalio}/client/implementation.rb +49 -48
- data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
- data/lib/{temporal → temporalio}/client.rb +19 -32
- data/lib/{temporal → temporalio}/connection.rb +238 -223
- data/lib/{temporal → temporalio}/data_converter.rb +76 -35
- data/lib/{temporal → temporalio}/error/failure.rb +6 -6
- data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
- data/lib/{temporal → temporalio}/errors.rb +19 -1
- data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
- data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/{temporal → temporalio}/interceptor/chain.rb +2 -1
- data/lib/{temporal → temporalio}/interceptor/client.rb +22 -1
- data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
- data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
- data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
- data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
- data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/{temporal → temporalio}/retry_policy.rb +4 -4
- data/lib/{temporal → temporalio}/retry_state.rb +1 -1
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +92 -0
- data/lib/temporalio/worker/activity_worker.rb +138 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +88 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +198 -0
- data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
- data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
- data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
- data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
- data/lib/temporalio.rb +12 -3
- data/temporalio.gemspec +7 -3
- metadata +79 -56
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
- data/bridge/sdk-core/core/src/log_export.rs +0 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
- data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -26
- data/lib/temporal/bridge.rb +0 -14
- data/lib/temporal/failure_converter.rb +0 -8
- data/lib/temporal/payload_converter.rb +0 -14
- data/lib/temporal/runtime.rb +0 -22
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -8
|
@@ -1,30 +1,60 @@
|
|
|
1
1
|
require 'temporal/api/common/v1/message_pb'
|
|
2
|
-
require '
|
|
2
|
+
require 'temporalio/errors'
|
|
3
|
+
require 'temporalio/failure_converter'
|
|
4
|
+
require 'temporalio/payload_converter'
|
|
3
5
|
|
|
4
|
-
module
|
|
6
|
+
module Temporalio
|
|
5
7
|
class DataConverter
|
|
6
|
-
class MissingPayload <
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
class MissingPayload < Temporalio::Error; end
|
|
9
|
+
|
|
10
|
+
# Initialize a new data converter with optional payload converter, codecs and failure converter.
|
|
11
|
+
#
|
|
12
|
+
# @param payload_converter [Temporalio::PayloadConverter::Base] A custom payload converter for
|
|
13
|
+
# converting Ruby values to/from protos. See {Temporalio::PayloadConverter::Base} for the
|
|
14
|
+
# interface definition.
|
|
15
|
+
# @param payload_codecs [Array<Temporalio::PayloadCodec::Base>] A list of payload codecs to
|
|
16
|
+
# transform payload protos. See {Temporalio::PayloadCodec::Base} for the interface definition.
|
|
17
|
+
# @param failure_converter [Temporalio::FailureConverter::Base] A custom failure converter for
|
|
18
|
+
# converting Exceptions to/from protos. See {Temporalio::FailureConverter::Base} for the
|
|
19
|
+
# interface definition.
|
|
20
|
+
#
|
|
21
|
+
# @see https://docs.temporal.io/concepts/what-is-a-data-converter for more information on
|
|
22
|
+
# payload converters and codecs.
|
|
23
|
+
def initialize(
|
|
24
|
+
payload_converter: Temporalio::PayloadConverter::DEFAULT,
|
|
25
|
+
payload_codecs: [],
|
|
26
|
+
failure_converter: Temporalio::FailureConverter::DEFAULT
|
|
27
|
+
)
|
|
9
28
|
@payload_converter = payload_converter
|
|
10
29
|
@payload_codecs = payload_codecs
|
|
11
30
|
@failure_converter = failure_converter
|
|
12
31
|
end
|
|
13
32
|
|
|
33
|
+
def to_payload(value)
|
|
34
|
+
payload = value_to_payload(value)
|
|
35
|
+
encoded_payload = encode([payload]).first
|
|
36
|
+
raise MissingPayload, 'Payload Codecs returned no payloads' unless encoded_payload
|
|
37
|
+
|
|
38
|
+
encoded_payload
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_payload_array(data)
|
|
42
|
+
return [] if data.nil? || Array(data).empty?
|
|
43
|
+
|
|
44
|
+
payloads = Array(data).map { |value| value_to_payload(value) }
|
|
45
|
+
encode(payloads)
|
|
46
|
+
end
|
|
47
|
+
|
|
14
48
|
def to_payloads(data)
|
|
15
49
|
return if data.nil? || Array(data).empty?
|
|
16
50
|
|
|
17
|
-
payloads = Array(data).map { |value|
|
|
18
|
-
|
|
51
|
+
payloads = Array(data).map { |value| value_to_payload(value) }
|
|
52
|
+
Temporalio::Api::Common::V1::Payloads.new(payloads: encode(payloads))
|
|
19
53
|
end
|
|
20
54
|
|
|
21
55
|
def to_payload_map(data)
|
|
22
56
|
data.to_h do |key, value|
|
|
23
|
-
|
|
24
|
-
encoded_payload = encode([payload]).first
|
|
25
|
-
raise MissingPayload, 'Payload Codecs returned no payloads' unless encoded_payload
|
|
26
|
-
|
|
27
|
-
[key.to_s, encoded_payload]
|
|
57
|
+
[key.to_s, to_payload(value)]
|
|
28
58
|
end
|
|
29
59
|
end
|
|
30
60
|
|
|
@@ -33,25 +63,36 @@ module Temporal
|
|
|
33
63
|
encode_failure(failure)
|
|
34
64
|
end
|
|
35
65
|
|
|
66
|
+
def from_payload(payload)
|
|
67
|
+
decoded_payload = decode([payload]).first
|
|
68
|
+
raise MissingPayload, 'Payload Codecs returned no payloads' unless decoded_payload
|
|
69
|
+
|
|
70
|
+
payload_to_value(decoded_payload)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def from_payload_array(payloads)
|
|
74
|
+
return [] if payloads.empty?
|
|
75
|
+
|
|
76
|
+
decode(payloads)
|
|
77
|
+
.map { |payload| payload_to_value(payload) }
|
|
78
|
+
end
|
|
79
|
+
|
|
36
80
|
def from_payloads(payloads)
|
|
37
81
|
return unless payloads
|
|
38
82
|
|
|
39
83
|
decode(payloads.payloads)
|
|
40
|
-
.map { |payload|
|
|
84
|
+
.map { |payload| payload_to_value(payload) }
|
|
41
85
|
end
|
|
42
86
|
|
|
43
87
|
def from_payload_map(payload_map)
|
|
44
88
|
return unless payload_map
|
|
45
89
|
|
|
46
90
|
# Protobuf's Hash isn't compatible with the native Hash, ignore rubocop here
|
|
47
|
-
# rubocop:disable Style/MapToHash
|
|
91
|
+
# rubocop:disable Style/MapToHash, Style/HashTransformValues
|
|
48
92
|
payload_map.map do |key, payload|
|
|
49
|
-
|
|
50
|
-
raise MissingPayload, 'Payload Codecs returned no payloads' unless decoded_payload
|
|
51
|
-
|
|
52
|
-
[key, from_payload(decoded_payload)]
|
|
93
|
+
[key, from_payload(payload)]
|
|
53
94
|
end.to_h
|
|
54
|
-
# rubocop:enable Style/MapToHash
|
|
95
|
+
# rubocop:enable Style/MapToHash, Style/HashTransformValues
|
|
55
96
|
end
|
|
56
97
|
|
|
57
98
|
def from_failure(failure)
|
|
@@ -65,6 +106,14 @@ module Temporal
|
|
|
65
106
|
|
|
66
107
|
attr_reader :payload_converter, :payload_codecs, :failure_converter
|
|
67
108
|
|
|
109
|
+
def value_to_payload(value)
|
|
110
|
+
payload_converter.to_payload(value)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def payload_to_value(payload)
|
|
114
|
+
payload_converter.from_payload(payload)
|
|
115
|
+
end
|
|
116
|
+
|
|
68
117
|
def encode(payloads)
|
|
69
118
|
return [] unless payloads
|
|
70
119
|
|
|
@@ -85,14 +134,6 @@ module Temporal
|
|
|
85
134
|
payloads
|
|
86
135
|
end
|
|
87
136
|
|
|
88
|
-
def to_payload(data)
|
|
89
|
-
payload_converter.to_payload(data)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def from_payload(payload)
|
|
93
|
-
payload_converter.from_payload(payload)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
137
|
def encode_failure(failure)
|
|
97
138
|
failure = failure.dup
|
|
98
139
|
|
|
@@ -100,19 +141,19 @@ module Temporal
|
|
|
100
141
|
failure.cause = failure.cause ? encode_failure(failure.cause) : nil
|
|
101
142
|
|
|
102
143
|
if failure.application_failure_info
|
|
103
|
-
failure.application_failure_info.details =
|
|
144
|
+
failure.application_failure_info.details = Temporalio::Api::Common::V1::Payloads.new(
|
|
104
145
|
payloads: encode(failure.application_failure_info.details&.payloads).to_a,
|
|
105
146
|
)
|
|
106
147
|
elsif failure.timeout_failure_info
|
|
107
|
-
failure.timeout_failure_info.last_heartbeat_details =
|
|
148
|
+
failure.timeout_failure_info.last_heartbeat_details = Temporalio::Api::Common::V1::Payloads.new(
|
|
108
149
|
payloads: encode(failure.timeout_failure_info.last_heartbeat_details&.payloads).to_a,
|
|
109
150
|
)
|
|
110
151
|
elsif failure.canceled_failure_info
|
|
111
|
-
failure.canceled_failure_info.details =
|
|
152
|
+
failure.canceled_failure_info.details = Temporalio::Api::Common::V1::Payloads.new(
|
|
112
153
|
payloads: encode(failure.canceled_failure_info.details&.payloads).to_a,
|
|
113
154
|
)
|
|
114
155
|
elsif failure.reset_workflow_failure_info
|
|
115
|
-
failure.reset_workflow_failure_info.last_heartbeat_details =
|
|
156
|
+
failure.reset_workflow_failure_info.last_heartbeat_details = Temporalio::Api::Common::V1::Payloads.new(
|
|
116
157
|
payloads: encode(failure.reset_workflow_failure_info.last_heartbeat_details&.payloads).to_a,
|
|
117
158
|
)
|
|
118
159
|
end
|
|
@@ -127,19 +168,19 @@ module Temporal
|
|
|
127
168
|
failure.cause = failure.cause ? decode_failure(failure.cause) : nil
|
|
128
169
|
|
|
129
170
|
if failure.application_failure_info
|
|
130
|
-
failure.application_failure_info.details =
|
|
171
|
+
failure.application_failure_info.details = Temporalio::Api::Common::V1::Payloads.new(
|
|
131
172
|
payloads: decode(failure.application_failure_info.details&.payloads).to_a,
|
|
132
173
|
)
|
|
133
174
|
elsif failure.timeout_failure_info
|
|
134
|
-
failure.timeout_failure_info.last_heartbeat_details =
|
|
175
|
+
failure.timeout_failure_info.last_heartbeat_details = Temporalio::Api::Common::V1::Payloads.new(
|
|
135
176
|
payloads: decode(failure.timeout_failure_info.last_heartbeat_details&.payloads).to_a,
|
|
136
177
|
)
|
|
137
178
|
elsif failure.canceled_failure_info
|
|
138
|
-
failure.canceled_failure_info.details =
|
|
179
|
+
failure.canceled_failure_info.details = Temporalio::Api::Common::V1::Payloads.new(
|
|
139
180
|
payloads: decode(failure.canceled_failure_info.details&.payloads).to_a,
|
|
140
181
|
)
|
|
141
182
|
elsif failure.reset_workflow_failure_info
|
|
142
|
-
failure.reset_workflow_failure_info.last_heartbeat_details =
|
|
183
|
+
failure.reset_workflow_failure_info.last_heartbeat_details = Temporalio::Api::Common::V1::Payloads.new(
|
|
143
184
|
payloads: decode(failure.reset_workflow_failure_info.last_heartbeat_details&.payloads).to_a,
|
|
144
185
|
)
|
|
145
186
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# TODO: Figure out the hierarchy
|
|
2
|
-
require '
|
|
2
|
+
require 'temporalio/errors'
|
|
3
3
|
|
|
4
|
-
module
|
|
4
|
+
module Temporalio
|
|
5
5
|
class Error
|
|
6
6
|
# Base for runtime failures during workflow/activity execution.
|
|
7
7
|
class Failure < Error
|
|
8
|
-
# @return [
|
|
8
|
+
# @return [Temporalio::Api::Failure::V1::Failure, nil] Original proto failure
|
|
9
9
|
attr_reader :raw
|
|
10
10
|
|
|
11
11
|
def initialize(message, raw: nil, cause: nil)
|
|
@@ -46,7 +46,7 @@ module Temporal
|
|
|
46
46
|
|
|
47
47
|
# Error raised on workflow/activity timeout.
|
|
48
48
|
class TimeoutError < Failure
|
|
49
|
-
# @return [Symbol] Type of timeout error. Refer to {
|
|
49
|
+
# @return [Symbol] Type of timeout error. Refer to {Temporalio::TimeoutType}.
|
|
50
50
|
attr_reader :type
|
|
51
51
|
|
|
52
52
|
# @return [Array<any>] Last heartbeat details if this is for an activity heartbeat.
|
|
@@ -119,7 +119,7 @@ module Temporal
|
|
|
119
119
|
# @return [String] Activity ID for this error.
|
|
120
120
|
attr_reader :activity_id
|
|
121
121
|
|
|
122
|
-
# @return [Symbol] Retry state for this error. Refer to {
|
|
122
|
+
# @return [Symbol] Retry state for this error. Refer to {Temporalio::RetryState}.
|
|
123
123
|
attr_reader :retry_state
|
|
124
124
|
|
|
125
125
|
def initialize(
|
|
@@ -164,7 +164,7 @@ module Temporal
|
|
|
164
164
|
# @return [Integer] Started event ID for this error.
|
|
165
165
|
attr_reader :started_event_id
|
|
166
166
|
|
|
167
|
-
# @return [Symbol] Retry state for this error. Refer to {
|
|
167
|
+
# @return [Symbol] Retry state for this error. Refer to {Temporalio::RetryState}.
|
|
168
168
|
attr_reader :retry_state
|
|
169
169
|
|
|
170
170
|
def initialize(
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'temporalio/errors'
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module Temporalio
|
|
4
4
|
class Error
|
|
5
5
|
# Used as a wrapper to perserve failure hierarchy in nested calls
|
|
6
6
|
# i.e. WorkflowFailure(ActivityError(WorkflowFailure(CancelledError)))
|
|
7
|
+
#
|
|
8
|
+
# @api private
|
|
7
9
|
class WorkflowFailure < Error
|
|
8
10
|
attr_reader :cause
|
|
9
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Temporalio
|
|
2
2
|
# Superclass for all Temporal errors
|
|
3
3
|
class Error < StandardError
|
|
4
4
|
# Superclass for RPC and proto related errors
|
|
@@ -18,5 +18,23 @@ module Temporal
|
|
|
18
18
|
@status = status
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
# Superclass for internal errors
|
|
23
|
+
class Internal < Error; end
|
|
24
|
+
|
|
25
|
+
class WorkerShutdown < Internal; end
|
|
26
|
+
|
|
27
|
+
# This error is used within the SDK to communicate Activity cancellations
|
|
28
|
+
# (and whether it was requested by server or not)
|
|
29
|
+
class ActivityCancelled < Internal
|
|
30
|
+
def initialize(reason, by_request)
|
|
31
|
+
super(reason)
|
|
32
|
+
@by_request = by_request
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def by_request?
|
|
36
|
+
@by_request
|
|
37
|
+
end
|
|
38
|
+
end
|
|
21
39
|
end
|
|
22
40
|
end
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Temporalio
|
|
2
2
|
module FailureConverter
|
|
3
3
|
# @abstract Use this Interface for implementing your failure converter.
|
|
4
4
|
class Base
|
|
5
5
|
# Convert an Error object to a proto Failure.
|
|
6
6
|
#
|
|
7
7
|
# @param _error [Exception] An Error to be converter.
|
|
8
|
-
# @param _payload_converter [
|
|
8
|
+
# @param _payload_converter [Temporalio::PayloadConverter::Base] A payload converter.
|
|
9
9
|
#
|
|
10
|
-
# @return [
|
|
10
|
+
# @return [Temporalio::Api::Failure::V1::Failure]
|
|
11
11
|
def to_failure(_error, _payload_converter)
|
|
12
12
|
raise NoMethodError, 'must implement #to_failure'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# Convert an proto Failure object to an Error.
|
|
16
16
|
#
|
|
17
|
-
# @param _failure [
|
|
18
|
-
# @param _payload_converter [
|
|
17
|
+
# @param _failure [Temporalio::Api::Failure::V1::Failure] A proto Failure to be converted.
|
|
18
|
+
# @param _payload_converter [Temporalio::PayloadConverter::Base] A payload converter.
|
|
19
19
|
#
|
|
20
20
|
# @return [Exception]
|
|
21
21
|
def from_failure(_failure, _payload_converter)
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
require 'temporal/api/common/v1/message_pb'
|
|
2
2
|
require 'temporal/api/failure/v1/message_pb'
|
|
3
|
-
require '
|
|
4
|
-
require '
|
|
5
|
-
require '
|
|
6
|
-
require '
|
|
3
|
+
require 'temporalio/error/failure'
|
|
4
|
+
require 'temporalio/failure_converter/base'
|
|
5
|
+
require 'temporalio/retry_state'
|
|
6
|
+
require 'temporalio/timeout_type'
|
|
7
7
|
|
|
8
|
-
module
|
|
8
|
+
module Temporalio
|
|
9
9
|
module FailureConverter
|
|
10
|
+
# A default implementation of a FailureConverter.
|
|
11
|
+
#
|
|
12
|
+
# Use {Temporalio::DataConverter} for the set of helper method for interaction with converters.
|
|
13
|
+
#
|
|
14
|
+
# @api private
|
|
10
15
|
class Basic < Base
|
|
11
16
|
def initialize(encode_common_attributes: false)
|
|
12
17
|
super()
|
|
@@ -15,25 +20,25 @@ module Temporal
|
|
|
15
20
|
end
|
|
16
21
|
|
|
17
22
|
def to_failure(error, payload_converter)
|
|
18
|
-
return error.raw if error.is_a?(
|
|
23
|
+
return error.raw if error.is_a?(Temporalio::Error::Failure) && error.raw
|
|
19
24
|
|
|
20
25
|
failure =
|
|
21
26
|
case error
|
|
22
|
-
when
|
|
27
|
+
when Temporalio::Error::ApplicationError
|
|
23
28
|
to_application_failure(error, payload_converter)
|
|
24
|
-
when
|
|
29
|
+
when Temporalio::Error::TimeoutError
|
|
25
30
|
to_timeout_failure(error, payload_converter)
|
|
26
|
-
when
|
|
31
|
+
when Temporalio::Error::CancelledError
|
|
27
32
|
to_cancelled_failure(error, payload_converter)
|
|
28
|
-
when
|
|
33
|
+
when Temporalio::Error::TerminatedError
|
|
29
34
|
to_terminated_failure(error, payload_converter)
|
|
30
|
-
when
|
|
35
|
+
when Temporalio::Error::ServerError
|
|
31
36
|
to_server_failure(error, payload_converter)
|
|
32
|
-
when
|
|
37
|
+
when Temporalio::Error::ResetWorkflowError
|
|
33
38
|
to_reset_workflow_failure(error, payload_converter)
|
|
34
|
-
when
|
|
39
|
+
when Temporalio::Error::ActivityError
|
|
35
40
|
to_activity_failure(error, payload_converter)
|
|
36
|
-
when
|
|
41
|
+
when Temporalio::Error::ChildWorkflowError
|
|
37
42
|
to_child_workflow_execution_failure(error, payload_converter)
|
|
38
43
|
else
|
|
39
44
|
to_generic_failure(error, payload_converter)
|
|
@@ -41,7 +46,8 @@ module Temporal
|
|
|
41
46
|
|
|
42
47
|
failure.message = error.message
|
|
43
48
|
failure.stack_trace = error.backtrace&.join("\n") || ''
|
|
44
|
-
|
|
49
|
+
# RBS: StandardError fallback is only needed to satisfy steep - https://github.com/soutaro/steep/issues/477
|
|
50
|
+
failure.cause = to_failure(error.cause || StandardError.new, payload_converter) if error.cause
|
|
45
51
|
|
|
46
52
|
if encode_common_attributes?
|
|
47
53
|
failure.encoded_attributes = payload_converter.to_payload(
|
|
@@ -102,7 +108,7 @@ module Temporal
|
|
|
102
108
|
return if data.nil? || Array(data).empty?
|
|
103
109
|
|
|
104
110
|
payloads = Array(data).map { |value| payload_converter.to_payload(value) }
|
|
105
|
-
|
|
111
|
+
Temporalio::Api::Common::V1::Payloads.new(payloads: payloads)
|
|
106
112
|
end
|
|
107
113
|
|
|
108
114
|
def from_payloads(payloads, payload_converter)
|
|
@@ -130,8 +136,8 @@ module Temporal
|
|
|
130
136
|
end
|
|
131
137
|
|
|
132
138
|
def to_application_failure(error, payload_converter)
|
|
133
|
-
|
|
134
|
-
application_failure_info:
|
|
139
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
140
|
+
application_failure_info: Temporalio::Api::Failure::V1::ApplicationFailureInfo.new(
|
|
135
141
|
type: error.type,
|
|
136
142
|
non_retryable: error.non_retryable,
|
|
137
143
|
details: to_payloads(error.details, payload_converter),
|
|
@@ -140,84 +146,84 @@ module Temporal
|
|
|
140
146
|
end
|
|
141
147
|
|
|
142
148
|
def to_timeout_failure(error, payload_converter)
|
|
143
|
-
|
|
144
|
-
timeout_failure_info:
|
|
145
|
-
timeout_type:
|
|
149
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
150
|
+
timeout_failure_info: Temporalio::Api::Failure::V1::TimeoutFailureInfo.new(
|
|
151
|
+
timeout_type: Temporalio::TimeoutType.to_raw(error.type),
|
|
146
152
|
last_heartbeat_details: to_payloads(error.last_heartbeat_details, payload_converter),
|
|
147
153
|
),
|
|
148
154
|
)
|
|
149
155
|
end
|
|
150
156
|
|
|
151
157
|
def to_cancelled_failure(error, payload_converter)
|
|
152
|
-
|
|
153
|
-
canceled_failure_info:
|
|
158
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
159
|
+
canceled_failure_info: Temporalio::Api::Failure::V1::CanceledFailureInfo.new(
|
|
154
160
|
details: to_payloads(error.details, payload_converter),
|
|
155
161
|
),
|
|
156
162
|
)
|
|
157
163
|
end
|
|
158
164
|
|
|
159
165
|
def to_terminated_failure(_error, _payload_converter)
|
|
160
|
-
|
|
161
|
-
terminated_failure_info:
|
|
166
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
167
|
+
terminated_failure_info: Temporalio::Api::Failure::V1::TerminatedFailureInfo.new,
|
|
162
168
|
)
|
|
163
169
|
end
|
|
164
170
|
|
|
165
171
|
def to_server_failure(error, _payload_converter)
|
|
166
|
-
|
|
167
|
-
server_failure_info:
|
|
172
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
173
|
+
server_failure_info: Temporalio::Api::Failure::V1::ServerFailureInfo.new(
|
|
168
174
|
non_retryable: error.non_retryable,
|
|
169
175
|
),
|
|
170
176
|
)
|
|
171
177
|
end
|
|
172
178
|
|
|
173
179
|
def to_reset_workflow_failure(error, payload_converter)
|
|
174
|
-
|
|
175
|
-
reset_workflow_failure_info:
|
|
180
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
181
|
+
reset_workflow_failure_info: Temporalio::Api::Failure::V1::ResetWorkflowFailureInfo.new(
|
|
176
182
|
last_heartbeat_details: to_payloads(error.last_heartbeat_details, payload_converter),
|
|
177
183
|
),
|
|
178
184
|
)
|
|
179
185
|
end
|
|
180
186
|
|
|
181
187
|
def to_activity_failure(error, _payload_converter)
|
|
182
|
-
|
|
183
|
-
activity_failure_info:
|
|
188
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
189
|
+
activity_failure_info: Temporalio::Api::Failure::V1::ActivityFailureInfo.new(
|
|
184
190
|
scheduled_event_id: error.scheduled_event_id,
|
|
185
191
|
started_event_id: error.started_event_id,
|
|
186
192
|
identity: error.identity,
|
|
187
|
-
activity_type:
|
|
193
|
+
activity_type: Temporalio::Api::Common::V1::ActivityType.new(name: error.activity_name || ''),
|
|
188
194
|
activity_id: error.activity_id,
|
|
189
|
-
retry_state:
|
|
195
|
+
retry_state: Temporalio::RetryState.to_raw(error.retry_state),
|
|
190
196
|
),
|
|
191
197
|
)
|
|
192
198
|
end
|
|
193
199
|
|
|
194
200
|
def to_child_workflow_execution_failure(error, _payload_converter)
|
|
195
|
-
|
|
201
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
196
202
|
child_workflow_execution_failure_info:
|
|
197
|
-
|
|
203
|
+
Temporalio::Api::Failure::V1::ChildWorkflowExecutionFailureInfo.new(
|
|
198
204
|
namespace: error.namespace,
|
|
199
|
-
workflow_execution:
|
|
205
|
+
workflow_execution: Temporalio::Api::Common::V1::WorkflowExecution.new(
|
|
200
206
|
workflow_id: error.workflow_id || '',
|
|
201
207
|
run_id: error.run_id || '',
|
|
202
208
|
),
|
|
203
|
-
workflow_type:
|
|
209
|
+
workflow_type: Temporalio::Api::Common::V1::WorkflowType.new(name: error.workflow_name || ''),
|
|
204
210
|
initiated_event_id: error.initiated_event_id,
|
|
205
211
|
started_event_id: error.started_event_id,
|
|
206
|
-
retry_state:
|
|
212
|
+
retry_state: Temporalio::RetryState.to_raw(error.retry_state),
|
|
207
213
|
),
|
|
208
214
|
)
|
|
209
215
|
end
|
|
210
216
|
|
|
211
217
|
def to_generic_failure(error, _payload_converter)
|
|
212
|
-
|
|
213
|
-
application_failure_info:
|
|
218
|
+
Temporalio::Api::Failure::V1::Failure.new(
|
|
219
|
+
application_failure_info: Temporalio::Api::Failure::V1::ApplicationFailureInfo.new(
|
|
214
220
|
type: error.class.name,
|
|
215
221
|
),
|
|
216
222
|
)
|
|
217
223
|
end
|
|
218
224
|
|
|
219
225
|
def from_application_failure(failure, failure_info, cause, payload_converter)
|
|
220
|
-
|
|
226
|
+
Temporalio::Error::ApplicationError.new(
|
|
221
227
|
failure.message || 'Application error',
|
|
222
228
|
type: failure_info.type,
|
|
223
229
|
details: from_payloads(failure_info.details, payload_converter),
|
|
@@ -228,9 +234,9 @@ module Temporal
|
|
|
228
234
|
end
|
|
229
235
|
|
|
230
236
|
def from_timeout_failure(failure, failure_info, cause, payload_converter)
|
|
231
|
-
|
|
237
|
+
Temporalio::Error::TimeoutError.new(
|
|
232
238
|
failure.message || 'Timeout',
|
|
233
|
-
type:
|
|
239
|
+
type: Temporalio::TimeoutType.from_raw(failure_info.timeout_type),
|
|
234
240
|
last_heartbeat_details: from_payloads(failure_info.last_heartbeat_details, payload_converter),
|
|
235
241
|
raw: failure,
|
|
236
242
|
cause: cause,
|
|
@@ -238,7 +244,7 @@ module Temporal
|
|
|
238
244
|
end
|
|
239
245
|
|
|
240
246
|
def from_cancelled_failure(failure, failure_info, cause, payload_converter)
|
|
241
|
-
|
|
247
|
+
Temporalio::Error::CancelledError.new(
|
|
242
248
|
failure.message || 'Cancelled',
|
|
243
249
|
details: from_payloads(failure_info.details, payload_converter),
|
|
244
250
|
raw: failure,
|
|
@@ -247,7 +253,7 @@ module Temporal
|
|
|
247
253
|
end
|
|
248
254
|
|
|
249
255
|
def from_terminated_failure(failure, _failure_info, cause, _payload_converter)
|
|
250
|
-
|
|
256
|
+
Temporalio::Error::TerminatedError.new(
|
|
251
257
|
failure.message || 'Terminated',
|
|
252
258
|
raw: failure,
|
|
253
259
|
cause: cause,
|
|
@@ -255,7 +261,7 @@ module Temporal
|
|
|
255
261
|
end
|
|
256
262
|
|
|
257
263
|
def from_server_failure(failure, failure_info, cause, _payload_converter)
|
|
258
|
-
|
|
264
|
+
Temporalio::Error::ServerError.new(
|
|
259
265
|
failure.message || 'Server error',
|
|
260
266
|
non_retryable: failure_info.non_retryable,
|
|
261
267
|
raw: failure,
|
|
@@ -264,7 +270,7 @@ module Temporal
|
|
|
264
270
|
end
|
|
265
271
|
|
|
266
272
|
def from_reset_workflow_failure(failure, failure_info, cause, payload_converter)
|
|
267
|
-
|
|
273
|
+
Temporalio::Error::ResetWorkflowError.new(
|
|
268
274
|
failure.message || 'Reset workflow error',
|
|
269
275
|
last_heartbeat_details: from_payloads(failure_info.last_heartbeat_details, payload_converter),
|
|
270
276
|
raw: failure,
|
|
@@ -273,21 +279,21 @@ module Temporal
|
|
|
273
279
|
end
|
|
274
280
|
|
|
275
281
|
def from_activity_failure(failure, failure_info, cause, _payload_converter)
|
|
276
|
-
|
|
282
|
+
Temporalio::Error::ActivityError.new(
|
|
277
283
|
failure.message || 'Activity error',
|
|
278
284
|
scheduled_event_id: failure_info.scheduled_event_id,
|
|
279
285
|
started_event_id: failure_info.started_event_id,
|
|
280
286
|
identity: failure_info.identity,
|
|
281
287
|
activity_name: failure_info.activity_type&.name,
|
|
282
288
|
activity_id: failure_info.activity_id,
|
|
283
|
-
retry_state:
|
|
289
|
+
retry_state: Temporalio::RetryState.from_raw(failure_info.retry_state),
|
|
284
290
|
raw: failure,
|
|
285
291
|
cause: cause,
|
|
286
292
|
)
|
|
287
293
|
end
|
|
288
294
|
|
|
289
295
|
def from_child_workflow_execution_failure(failure, failure_info, cause, _payload_converter)
|
|
290
|
-
|
|
296
|
+
Temporalio::Error::ChildWorkflowError.new(
|
|
291
297
|
failure.message || 'Child workflow error',
|
|
292
298
|
namespace: failure_info.namespace,
|
|
293
299
|
workflow_id: failure_info.workflow_execution&.workflow_id,
|
|
@@ -295,14 +301,14 @@ module Temporal
|
|
|
295
301
|
workflow_name: failure_info.workflow_type&.name,
|
|
296
302
|
initiated_event_id: failure_info.initiated_event_id,
|
|
297
303
|
started_event_id: failure_info.started_event_id,
|
|
298
|
-
retry_state:
|
|
304
|
+
retry_state: Temporalio::RetryState.from_raw(failure_info.retry_state),
|
|
299
305
|
raw: failure,
|
|
300
306
|
cause: cause,
|
|
301
307
|
)
|
|
302
308
|
end
|
|
303
309
|
|
|
304
310
|
def from_generic_failure(failure, cause, _payload_converter)
|
|
305
|
-
|
|
311
|
+
Temporalio::Error::Failure.new(
|
|
306
312
|
failure.message || 'Failure error',
|
|
307
313
|
raw: failure,
|
|
308
314
|
cause: cause,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Temporalio
|
|
2
2
|
module Interceptor
|
|
3
|
+
# Base class for implementing Client side interceptors.
|
|
4
|
+
#
|
|
5
|
+
# @abstract
|
|
3
6
|
class Client
|
|
4
7
|
class StartWorkflowInput < Struct.new(
|
|
5
8
|
:workflow,
|
|
@@ -74,26 +77,44 @@ module Temporal
|
|
|
74
77
|
keyword_init: true,
|
|
75
78
|
); end
|
|
76
79
|
|
|
80
|
+
# Interceptor for {Temporalio::Client#start_workflow}.
|
|
81
|
+
#
|
|
82
|
+
# @param input [StartWorkflowInput]
|
|
77
83
|
def start_workflow(input)
|
|
78
84
|
yield(input)
|
|
79
85
|
end
|
|
80
86
|
|
|
87
|
+
# Interceptor for {Temporalio::Client::WorkflowHandle#describe}.
|
|
88
|
+
#
|
|
89
|
+
# @param input [DescribeWorkflowInput]
|
|
81
90
|
def describe_workflow(input)
|
|
82
91
|
yield(input)
|
|
83
92
|
end
|
|
84
93
|
|
|
94
|
+
# Interceptor for {Temporalio::Client::WorkflowHandle#query}.
|
|
95
|
+
#
|
|
96
|
+
# @param input [QueryWorkflowInput]
|
|
85
97
|
def query_workflow(input)
|
|
86
98
|
yield(input)
|
|
87
99
|
end
|
|
88
100
|
|
|
101
|
+
# Interceptor for {Temporalio::Client::WorkflowHandle#signal}.
|
|
102
|
+
#
|
|
103
|
+
# @param input [SignalWorkflowInput]
|
|
89
104
|
def signal_workflow(input)
|
|
90
105
|
yield(input)
|
|
91
106
|
end
|
|
92
107
|
|
|
108
|
+
# Interceptor for {Temporalio::Client::WorkflowHandle#cancel}.
|
|
109
|
+
#
|
|
110
|
+
# @param input [CancelWorkflowInput]
|
|
93
111
|
def cancel_workflow(input)
|
|
94
112
|
yield(input)
|
|
95
113
|
end
|
|
96
114
|
|
|
115
|
+
# Interceptor for {Temporalio::Client::WorkflowHandle#terminate}.
|
|
116
|
+
#
|
|
117
|
+
# @param input [TerminateWorkflowInput]
|
|
97
118
|
def terminate_workflow(input)
|
|
98
119
|
yield(input)
|
|
99
120
|
end
|