@temporalio/core-bridge 1.15.0 → 1.16.1
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.
- package/Cargo.lock +172 -70
- package/lib/native.d.ts +1 -1
- package/package.json +2 -2
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.github/workflows/per-pr.yml +6 -6
- package/sdk-core/AGENTS.md +41 -30
- package/sdk-core/Cargo.toml +3 -0
- package/sdk-core/README.md +15 -9
- package/sdk-core/crates/client/Cargo.toml +4 -0
- package/sdk-core/crates/client/README.md +139 -0
- package/sdk-core/crates/client/src/async_activity_handle.rs +297 -0
- package/sdk-core/crates/client/src/callback_based.rs +7 -0
- package/sdk-core/crates/client/src/errors.rs +294 -0
- package/sdk-core/crates/client/src/{raw.rs → grpc.rs} +280 -159
- package/sdk-core/crates/client/src/lib.rs +920 -1326
- package/sdk-core/crates/client/src/metrics.rs +24 -33
- package/sdk-core/crates/client/src/options_structs.rs +457 -0
- package/sdk-core/crates/client/src/replaceable.rs +5 -4
- package/sdk-core/crates/client/src/request_extensions.rs +8 -9
- package/sdk-core/crates/client/src/retry.rs +99 -54
- package/sdk-core/crates/client/src/{worker/mod.rs → worker.rs} +1 -1
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +61 -2
- package/sdk-core/crates/common/build.rs +742 -12
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/ci.yml +2 -0
- package/sdk-core/crates/common/protos/api_upstream/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/buf.yaml +0 -3
- package/sdk-core/crates/common/protos/api_upstream/cmd/check-path-conflicts/main.go +137 -0
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv2.json +1166 -770
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +1243 -750
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +4 -3
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/history/v1/message.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +16 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +64 -6
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +88 -33
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +4 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +5 -5
- package/sdk-core/crates/common/src/activity_definition.rs +20 -0
- package/sdk-core/crates/common/src/data_converters.rs +770 -0
- package/sdk-core/crates/common/src/envconfig.rs +5 -0
- package/sdk-core/crates/common/src/lib.rs +15 -211
- package/sdk-core/crates/common/src/payload_visitor.rs +648 -0
- package/sdk-core/crates/common/src/priority.rs +110 -0
- package/sdk-core/crates/common/src/protos/canned_histories.rs +3 -0
- package/sdk-core/crates/common/src/protos/history_builder.rs +45 -0
- package/sdk-core/crates/common/src/protos/history_info.rs +2 -0
- package/sdk-core/crates/common/src/protos/mod.rs +122 -27
- package/sdk-core/crates/common/src/protos/task_token.rs +3 -3
- package/sdk-core/crates/common/src/protos/utilities.rs +11 -0
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/log_export.rs +5 -7
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +268 -223
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/otel.rs +8 -13
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_meter.rs +49 -50
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_server.rs +2 -3
- package/sdk-core/crates/common/src/telemetry.rs +264 -4
- package/sdk-core/crates/common/src/worker.rs +68 -603
- package/sdk-core/crates/common/src/workflow_definition.rs +60 -0
- package/sdk-core/crates/macros/Cargo.toml +5 -1
- package/sdk-core/crates/macros/src/activities_definitions.rs +585 -0
- package/sdk-core/crates/macros/src/fsm_impl.rs +507 -0
- package/sdk-core/crates/macros/src/lib.rs +138 -512
- package/sdk-core/crates/macros/src/macro_utils.rs +106 -0
- package/sdk-core/crates/macros/src/workflow_definitions.rs +1224 -0
- package/sdk-core/crates/sdk/Cargo.toml +19 -6
- package/sdk-core/crates/sdk/README.md +415 -0
- package/sdk-core/crates/sdk/src/activities.rs +417 -0
- package/sdk-core/crates/sdk/src/interceptors.rs +1 -1
- package/sdk-core/crates/sdk/src/lib.rs +757 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +45 -35
- package/sdk-core/crates/sdk/src/workflow_context.rs +1033 -289
- package/sdk-core/crates/sdk/src/workflow_future.rs +277 -213
- package/sdk-core/crates/sdk/src/workflows.rs +711 -0
- package/sdk-core/crates/sdk-core/Cargo.toml +57 -64
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +41 -35
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +1 -1
- package/sdk-core/crates/sdk-core/src/abstractions.rs +6 -10
- package/sdk-core/crates/sdk-core/src/core_tests/activity_tasks.rs +6 -5
- package/sdk-core/crates/sdk-core/src/core_tests/mod.rs +13 -15
- package/sdk-core/crates/sdk-core/src/core_tests/queries.rs +21 -25
- package/sdk-core/crates/sdk-core/src/core_tests/replay_flag.rs +7 -10
- package/sdk-core/crates/sdk-core/src/core_tests/updates.rs +14 -17
- package/sdk-core/crates/sdk-core/src/core_tests/workers.rs +493 -26
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +4 -8
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +7 -7
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +41 -111
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +118 -19
- package/sdk-core/crates/sdk-core/src/protosext/mod.rs +2 -2
- package/sdk-core/crates/sdk-core/src/replay/mod.rs +14 -5
- package/sdk-core/crates/sdk-core/src/telemetry/metrics.rs +179 -196
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -280
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +6 -9
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- package/sdk-core/crates/sdk-core/src/worker/activities/local_activities.rs +11 -14
- package/sdk-core/crates/sdk-core/src/worker/activities.rs +16 -19
- package/sdk-core/crates/sdk-core/src/worker/client/mocks.rs +9 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +103 -81
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +7 -11
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1124 -229
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +145 -23
- package/sdk-core/crates/sdk-core/src/worker/slot_provider.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/fixed_size.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/resource_based.rs +13 -13
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +28 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +21 -22
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs +19 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +14 -18
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +4 -6
- package/sdk-core/crates/sdk-core/src/worker/workflow/run_cache.rs +4 -7
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_extraction.rs +2 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_poller.rs +8 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/workflow_stream.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/activities_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/basic_pass.rs +54 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.rs +18 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/multi_arg_pass.rs +48 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_input_pass.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_return_type_pass.rs +19 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +14 -5
- package/sdk-core/crates/sdk-core/tests/common/activity_functions.rs +55 -0
- package/sdk-core/crates/sdk-core/tests/common/mod.rs +241 -196
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +3 -5
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -64
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +298 -252
- package/sdk-core/crates/sdk-core/tests/integ_tests/async_activity_client_tests.rs +230 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/client_tests.rs +94 -57
- package/sdk-core/crates/sdk-core/tests/integ_tests/data_converter_tests.rs +381 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +16 -12
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +48 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +327 -255
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +50 -45
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +147 -126
- package/sdk-core/crates/sdk-core/tests/integ_tests/queries_tests.rs +103 -89
- package/sdk-core/crates/sdk-core/tests/integ_tests/update_tests.rs +609 -453
- package/sdk-core/crates/sdk-core/tests/integ_tests/visibility_tests.rs +80 -62
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +360 -231
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +248 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -43
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_client_tests.rs +180 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/activities.rs +428 -315
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -243
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/client_interactions.rs +552 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +101 -42
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -147
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1036
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -41
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +397 -238
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +414 -189
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/queries.rs +415 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/replay.rs +96 -36
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs +154 -137
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -105
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -54
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +363 -226
- package/sdk-core/crates/sdk-core/tests/main.rs +17 -15
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +207 -152
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +65 -34
- package/sdk-core/crates/sdk-core/tests/shared_tests/priority.rs +107 -84
- package/sdk-core/crates/sdk-core/tests/workflows_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/basic_pass.rs +49 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/minimal_pass.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +7 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +14 -14
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +83 -74
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +9 -14
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +1 -2
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +13 -13
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +6 -6
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +3 -4
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +62 -75
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +205 -318
- package/src/metrics.rs +22 -30
- package/src/runtime.rs +4 -5
- package/src/worker.rs +16 -19
- package/ts/native.ts +1 -1
- package/sdk-core/crates/client/src/workflow_handle/mod.rs +0 -212
- package/sdk-core/crates/common/src/errors.rs +0 -85
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +0 -129
- package/sdk-core/crates/sdk/src/activity_context.rs +0 -238
- package/sdk-core/crates/sdk/src/app_data.rs +0 -37
- package/sdk-core/crates/sdk-core/tests/integ_tests/activity_functions.rs +0 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//! Worker-specific client needs
|
|
2
2
|
|
|
3
3
|
pub(crate) mod mocks;
|
|
4
|
-
use crate::protosext::legacy_query_failure;
|
|
4
|
+
use crate::{protosext::legacy_query_failure, worker::WorkerVersioningStrategy};
|
|
5
5
|
use parking_lot::Mutex;
|
|
6
6
|
use prost_types::Duration as PbDuration;
|
|
7
7
|
use std::{
|
|
@@ -10,36 +10,34 @@ use std::{
|
|
|
10
10
|
time::{Duration, SystemTime},
|
|
11
11
|
};
|
|
12
12
|
use temporalio_client::{
|
|
13
|
-
|
|
14
|
-
WorkflowService,
|
|
13
|
+
Connection, Namespace, NamespacedClient, RetryOptions, SharedReplaceableClient,
|
|
14
|
+
grpc::WorkflowService,
|
|
15
15
|
request_extensions::{IsWorkerTaskLongPoll, NoRetryOnMatching, RetryConfigForCall},
|
|
16
16
|
worker::ClientWorkerSet,
|
|
17
17
|
};
|
|
18
|
-
use temporalio_common::{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
WorkflowExecution,
|
|
27
|
-
},
|
|
28
|
-
deployment,
|
|
29
|
-
enums::v1::{
|
|
30
|
-
TaskQueueKind, VersioningBehavior, WorkerVersioningMode, WorkflowTaskFailedCause,
|
|
31
|
-
},
|
|
32
|
-
failure::v1::Failure,
|
|
33
|
-
nexus,
|
|
34
|
-
protocol::v1::Message as ProtocolMessage,
|
|
35
|
-
query::v1::WorkflowQueryResult,
|
|
36
|
-
sdk::v1::WorkflowTaskCompletedMetadata,
|
|
37
|
-
taskqueue::v1::{StickyExecutionAttributes, TaskQueue, TaskQueueMetadata},
|
|
38
|
-
worker::v1::{WorkerHeartbeat, WorkerSlotsInfo},
|
|
39
|
-
workflowservice::v1::{get_system_info_response::Capabilities, *},
|
|
18
|
+
use temporalio_common::protos::{
|
|
19
|
+
TaskToken,
|
|
20
|
+
coresdk::{workflow_commands::QueryResult, workflow_completion},
|
|
21
|
+
temporal::api::{
|
|
22
|
+
command::v1::Command,
|
|
23
|
+
common::v1::{
|
|
24
|
+
MeteringMetadata, Payloads, WorkerVersionCapabilities, WorkerVersionStamp,
|
|
25
|
+
WorkflowExecution,
|
|
40
26
|
},
|
|
27
|
+
deployment,
|
|
28
|
+
enums::v1::{
|
|
29
|
+
TaskQueueKind, TaskQueueType, VersioningBehavior, WorkerVersioningMode,
|
|
30
|
+
WorkflowTaskFailedCause,
|
|
31
|
+
},
|
|
32
|
+
failure::v1::Failure,
|
|
33
|
+
nexus::{self, v1::NexusTaskFailure},
|
|
34
|
+
protocol::v1::Message as ProtocolMessage,
|
|
35
|
+
query::v1::WorkflowQueryResult,
|
|
36
|
+
sdk::v1::WorkflowTaskCompletedMetadata,
|
|
37
|
+
taskqueue::v1::{StickyExecutionAttributes, TaskQueue, TaskQueueMetadata},
|
|
38
|
+
worker::v1::{WorkerHeartbeat, WorkerSlotsInfo},
|
|
39
|
+
workflowservice::v1::{get_system_info_response::Capabilities, *},
|
|
41
40
|
},
|
|
42
|
-
worker::WorkerVersioningStrategy,
|
|
43
41
|
};
|
|
44
42
|
use tonic::IntoRequest;
|
|
45
43
|
use uuid::Uuid;
|
|
@@ -53,29 +51,33 @@ pub enum LegacyQueryResult {
|
|
|
53
51
|
|
|
54
52
|
/// Contains everything a worker needs to interact with the server
|
|
55
53
|
pub(crate) struct WorkerClientBag {
|
|
56
|
-
|
|
54
|
+
connection: SharedReplaceableClient<Connection>,
|
|
57
55
|
namespace: String,
|
|
58
|
-
identity: String,
|
|
59
56
|
worker_versioning_strategy: WorkerVersioningStrategy,
|
|
57
|
+
worker_instance_key: Uuid,
|
|
60
58
|
worker_heartbeat_map: Arc<Mutex<HashMap<String, ClientHeartbeatData>>>,
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
impl WorkerClientBag {
|
|
64
62
|
pub(crate) fn new(
|
|
65
|
-
|
|
63
|
+
connection: SharedReplaceableClient<Connection>,
|
|
66
64
|
namespace: String,
|
|
67
|
-
identity: String,
|
|
68
65
|
worker_versioning_strategy: WorkerVersioningStrategy,
|
|
66
|
+
worker_instance_key: Uuid,
|
|
69
67
|
) -> Self {
|
|
70
68
|
Self {
|
|
71
|
-
|
|
69
|
+
connection,
|
|
72
70
|
namespace,
|
|
73
|
-
identity,
|
|
74
71
|
worker_versioning_strategy,
|
|
72
|
+
worker_instance_key,
|
|
75
73
|
worker_heartbeat_map: Arc::new(Mutex::new(HashMap::new())),
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
|
|
77
|
+
fn identity(&self) -> String {
|
|
78
|
+
self.connection.inner_cow().identity().to_owned()
|
|
79
|
+
}
|
|
80
|
+
|
|
79
81
|
fn default_capabilities(&self) -> Capabilities {
|
|
80
82
|
self.capabilities().unwrap_or_default()
|
|
81
83
|
}
|
|
@@ -200,7 +202,7 @@ pub trait WorkerClient: Sync + Send {
|
|
|
200
202
|
async fn fail_nexus_task(
|
|
201
203
|
&self,
|
|
202
204
|
task_token: TaskToken,
|
|
203
|
-
error:
|
|
205
|
+
error: NexusTaskFailure,
|
|
204
206
|
) -> Result<RespondNexusTaskFailedResponse>;
|
|
205
207
|
/// Get the workflow execution history
|
|
206
208
|
async fn get_workflow_execution_history(
|
|
@@ -221,6 +223,8 @@ pub trait WorkerClient: Sync + Send {
|
|
|
221
223
|
async fn shutdown_worker(
|
|
222
224
|
&self,
|
|
223
225
|
sticky_task_queue: String,
|
|
226
|
+
task_queue: String,
|
|
227
|
+
task_queue_types: Vec<TaskQueueType>,
|
|
224
228
|
final_heartbeat: Option<WorkerHeartbeat>,
|
|
225
229
|
) -> Result<ShutdownWorkerResponse>;
|
|
226
230
|
/// Record a worker heartbeat
|
|
@@ -230,8 +234,8 @@ pub trait WorkerClient: Sync + Send {
|
|
|
230
234
|
worker_heartbeat: Vec<WorkerHeartbeat>,
|
|
231
235
|
) -> Result<RecordWorkerHeartbeatResponse>;
|
|
232
236
|
|
|
233
|
-
/// Replace the underlying
|
|
234
|
-
fn
|
|
237
|
+
/// Replace the underlying connection
|
|
238
|
+
fn replace_connection(&self, new_client: Connection);
|
|
235
239
|
/// Return server capabilities
|
|
236
240
|
fn capabilities(&self) -> Option<Capabilities>;
|
|
237
241
|
/// Return workers using this client
|
|
@@ -244,6 +248,8 @@ pub trait WorkerClient: Sync + Send {
|
|
|
244
248
|
fn identity(&self) -> String;
|
|
245
249
|
/// Get worker grouping key
|
|
246
250
|
fn worker_grouping_key(&self) -> Uuid;
|
|
251
|
+
/// Get worker instance key (unique per worker instance)
|
|
252
|
+
fn worker_instance_key(&self) -> Uuid;
|
|
247
253
|
/// Sets the client-reliant fields for WorkerHeartbeat. This also updates client-level tracking
|
|
248
254
|
/// of heartbeat fields, like last heartbeat timestamp.
|
|
249
255
|
fn set_heartbeat_client_fields(&self, heartbeat: &mut WorkerHeartbeat);
|
|
@@ -296,10 +302,11 @@ impl WorkerClient for WorkerClientBag {
|
|
|
296
302
|
let mut request = PollWorkflowTaskQueueRequest {
|
|
297
303
|
namespace: self.namespace.clone(),
|
|
298
304
|
task_queue: Some(task_queue),
|
|
299
|
-
identity: self.identity
|
|
305
|
+
identity: self.identity(),
|
|
300
306
|
binary_checksum: self.binary_checksum(),
|
|
301
307
|
worker_version_capabilities: self.worker_version_capabilities(),
|
|
302
308
|
deployment_options: self.deployment_options(),
|
|
309
|
+
worker_instance_key: self.worker_instance_key.to_string(),
|
|
303
310
|
}
|
|
304
311
|
.into_request();
|
|
305
312
|
request.extensions_mut().insert(IsWorkerTaskLongPoll);
|
|
@@ -311,7 +318,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
311
318
|
}
|
|
312
319
|
|
|
313
320
|
Ok(self
|
|
314
|
-
.
|
|
321
|
+
.connection
|
|
315
322
|
.clone()
|
|
316
323
|
.poll_workflow_task_queue(request)
|
|
317
324
|
.await?
|
|
@@ -331,12 +338,13 @@ impl WorkerClient for WorkerClientBag {
|
|
|
331
338
|
kind: TaskQueueKind::Normal as i32,
|
|
332
339
|
normal_name: "".to_string(),
|
|
333
340
|
}),
|
|
334
|
-
identity: self.identity
|
|
341
|
+
identity: self.identity(),
|
|
335
342
|
task_queue_metadata: act_options.max_tasks_per_sec.map(|tps| TaskQueueMetadata {
|
|
336
343
|
max_tasks_per_second: Some(tps),
|
|
337
344
|
}),
|
|
338
345
|
worker_version_capabilities: self.worker_version_capabilities(),
|
|
339
346
|
deployment_options: self.deployment_options(),
|
|
347
|
+
worker_instance_key: self.worker_instance_key.to_string(),
|
|
340
348
|
}
|
|
341
349
|
.into_request();
|
|
342
350
|
request.extensions_mut().insert(IsWorkerTaskLongPoll);
|
|
@@ -348,7 +356,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
348
356
|
}
|
|
349
357
|
|
|
350
358
|
Ok(self
|
|
351
|
-
.
|
|
359
|
+
.connection
|
|
352
360
|
.clone()
|
|
353
361
|
.poll_activity_task_queue(request)
|
|
354
362
|
.await?
|
|
@@ -368,10 +376,11 @@ impl WorkerClient for WorkerClientBag {
|
|
|
368
376
|
kind: TaskQueueKind::Normal as i32,
|
|
369
377
|
normal_name: "".to_string(),
|
|
370
378
|
}),
|
|
371
|
-
identity: self.identity
|
|
379
|
+
identity: self.identity(),
|
|
372
380
|
worker_version_capabilities: self.worker_version_capabilities(),
|
|
373
381
|
deployment_options: self.deployment_options(),
|
|
374
382
|
worker_heartbeat: Vec::new(),
|
|
383
|
+
worker_instance_key: self.worker_instance_key.to_string(),
|
|
375
384
|
}
|
|
376
385
|
.into_request();
|
|
377
386
|
request.extensions_mut().insert(IsWorkerTaskLongPoll);
|
|
@@ -383,7 +392,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
383
392
|
}
|
|
384
393
|
|
|
385
394
|
Ok(self
|
|
386
|
-
.
|
|
395
|
+
.connection
|
|
387
396
|
.clone()
|
|
388
397
|
.poll_nexus_task_queue(request)
|
|
389
398
|
.await?
|
|
@@ -399,7 +408,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
399
408
|
task_token: request.task_token.into(),
|
|
400
409
|
commands: request.commands,
|
|
401
410
|
messages: request.messages,
|
|
402
|
-
identity: self.identity
|
|
411
|
+
identity: self.identity(),
|
|
403
412
|
sticky_attributes: request.sticky_attributes,
|
|
404
413
|
return_new_workflow_task: request.return_new_workflow_task,
|
|
405
414
|
force_create_new_workflow_task: request.force_create_new_workflow_task,
|
|
@@ -434,7 +443,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
434
443
|
deployment_options: self.deployment_options(),
|
|
435
444
|
};
|
|
436
445
|
Ok(self
|
|
437
|
-
.
|
|
446
|
+
.connection
|
|
438
447
|
.clone()
|
|
439
448
|
.respond_workflow_task_completed(request.into_request())
|
|
440
449
|
.await?
|
|
@@ -447,14 +456,14 @@ impl WorkerClient for WorkerClientBag {
|
|
|
447
456
|
result: Option<Payloads>,
|
|
448
457
|
) -> Result<RespondActivityTaskCompletedResponse> {
|
|
449
458
|
Ok(self
|
|
450
|
-
.
|
|
459
|
+
.connection
|
|
451
460
|
.clone()
|
|
452
461
|
.respond_activity_task_completed(
|
|
453
462
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
454
463
|
RespondActivityTaskCompletedRequest {
|
|
455
464
|
task_token: task_token.0,
|
|
456
465
|
result,
|
|
457
|
-
identity: self.identity
|
|
466
|
+
identity: self.identity(),
|
|
458
467
|
namespace: self.namespace.clone(),
|
|
459
468
|
worker_version: self.worker_version_stamp(),
|
|
460
469
|
// Will never be set, deprecated.
|
|
@@ -473,12 +482,12 @@ impl WorkerClient for WorkerClientBag {
|
|
|
473
482
|
response: nexus::v1::Response,
|
|
474
483
|
) -> Result<RespondNexusTaskCompletedResponse> {
|
|
475
484
|
Ok(self
|
|
476
|
-
.
|
|
485
|
+
.connection
|
|
477
486
|
.clone()
|
|
478
487
|
.respond_nexus_task_completed(
|
|
479
488
|
RespondNexusTaskCompletedRequest {
|
|
480
489
|
namespace: self.namespace.clone(),
|
|
481
|
-
identity: self.identity
|
|
490
|
+
identity: self.identity(),
|
|
482
491
|
task_token: task_token.0,
|
|
483
492
|
response: Some(response),
|
|
484
493
|
}
|
|
@@ -494,13 +503,13 @@ impl WorkerClient for WorkerClientBag {
|
|
|
494
503
|
details: Option<Payloads>,
|
|
495
504
|
) -> Result<RecordActivityTaskHeartbeatResponse> {
|
|
496
505
|
Ok(self
|
|
497
|
-
.
|
|
506
|
+
.connection
|
|
498
507
|
.clone()
|
|
499
508
|
.record_activity_task_heartbeat(
|
|
500
509
|
RecordActivityTaskHeartbeatRequest {
|
|
501
510
|
task_token: task_token.0,
|
|
502
511
|
details,
|
|
503
|
-
identity: self.identity
|
|
512
|
+
identity: self.identity(),
|
|
504
513
|
namespace: self.namespace.clone(),
|
|
505
514
|
}
|
|
506
515
|
.into_request(),
|
|
@@ -515,14 +524,14 @@ impl WorkerClient for WorkerClientBag {
|
|
|
515
524
|
details: Option<Payloads>,
|
|
516
525
|
) -> Result<RespondActivityTaskCanceledResponse> {
|
|
517
526
|
Ok(self
|
|
518
|
-
.
|
|
527
|
+
.connection
|
|
519
528
|
.clone()
|
|
520
529
|
.respond_activity_task_canceled(
|
|
521
530
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
522
531
|
RespondActivityTaskCanceledRequest {
|
|
523
532
|
task_token: task_token.0,
|
|
524
533
|
details,
|
|
525
|
-
identity: self.identity
|
|
534
|
+
identity: self.identity(),
|
|
526
535
|
namespace: self.namespace.clone(),
|
|
527
536
|
worker_version: self.worker_version_stamp(),
|
|
528
537
|
// Will never be set, deprecated.
|
|
@@ -541,14 +550,14 @@ impl WorkerClient for WorkerClientBag {
|
|
|
541
550
|
failure: Option<Failure>,
|
|
542
551
|
) -> Result<RespondActivityTaskFailedResponse> {
|
|
543
552
|
Ok(self
|
|
544
|
-
.
|
|
553
|
+
.connection
|
|
545
554
|
.clone()
|
|
546
555
|
.respond_activity_task_failed(
|
|
547
556
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
548
557
|
RespondActivityTaskFailedRequest {
|
|
549
558
|
task_token: task_token.0,
|
|
550
559
|
failure,
|
|
551
|
-
identity: self.identity
|
|
560
|
+
identity: self.identity(),
|
|
552
561
|
namespace: self.namespace.clone(),
|
|
553
562
|
// TODO: Implement - https://github.com/temporalio/sdk-core/issues/293
|
|
554
563
|
last_heartbeat_details: None,
|
|
@@ -574,7 +583,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
574
583
|
task_token: task_token.0,
|
|
575
584
|
cause: cause as i32,
|
|
576
585
|
failure,
|
|
577
|
-
identity: self.identity
|
|
586
|
+
identity: self.identity(),
|
|
578
587
|
binary_checksum: self.binary_checksum(),
|
|
579
588
|
namespace: self.namespace.clone(),
|
|
580
589
|
messages: vec![],
|
|
@@ -584,7 +593,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
584
593
|
deployment_options: self.deployment_options(),
|
|
585
594
|
};
|
|
586
595
|
Ok(self
|
|
587
|
-
.
|
|
596
|
+
.connection
|
|
588
597
|
.clone()
|
|
589
598
|
.respond_workflow_task_failed(request.into_request())
|
|
590
599
|
.await?
|
|
@@ -594,17 +603,24 @@ impl WorkerClient for WorkerClientBag {
|
|
|
594
603
|
async fn fail_nexus_task(
|
|
595
604
|
&self,
|
|
596
605
|
task_token: TaskToken,
|
|
597
|
-
error:
|
|
606
|
+
error: NexusTaskFailure,
|
|
598
607
|
) -> Result<RespondNexusTaskFailedResponse> {
|
|
608
|
+
let (error, failure) = match error {
|
|
609
|
+
NexusTaskFailure::Legacy(handler_err) => (Some(handler_err), None),
|
|
610
|
+
NexusTaskFailure::Temporal(failure) => (None, Some(failure)),
|
|
611
|
+
};
|
|
612
|
+
|
|
599
613
|
Ok(self
|
|
600
|
-
.
|
|
614
|
+
.connection
|
|
601
615
|
.clone()
|
|
602
616
|
.respond_nexus_task_failed(
|
|
617
|
+
#[allow(deprecated)]
|
|
603
618
|
RespondNexusTaskFailedRequest {
|
|
604
619
|
namespace: self.namespace.clone(),
|
|
605
|
-
identity: self.identity
|
|
620
|
+
identity: self.identity(),
|
|
606
621
|
task_token: task_token.0,
|
|
607
|
-
|
|
622
|
+
failure,
|
|
623
|
+
error,
|
|
608
624
|
}
|
|
609
625
|
.into_request(),
|
|
610
626
|
)
|
|
@@ -619,7 +635,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
619
635
|
page_token: Vec<u8>,
|
|
620
636
|
) -> Result<GetWorkflowExecutionHistoryResponse> {
|
|
621
637
|
Ok(self
|
|
622
|
-
.
|
|
638
|
+
.connection
|
|
623
639
|
.clone()
|
|
624
640
|
.get_workflow_execution_history(
|
|
625
641
|
GetWorkflowExecutionHistoryRequest {
|
|
@@ -655,7 +671,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
655
671
|
let (_, completed_type, query_result, error_message) = query_result.into_components();
|
|
656
672
|
|
|
657
673
|
Ok(self
|
|
658
|
-
.
|
|
674
|
+
.connection
|
|
659
675
|
.clone()
|
|
660
676
|
.respond_query_task_completed(
|
|
661
677
|
RespondQueryTaskCompletedRequest {
|
|
@@ -675,7 +691,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
675
691
|
|
|
676
692
|
async fn describe_namespace(&self) -> Result<DescribeNamespaceResponse> {
|
|
677
693
|
Ok(self
|
|
678
|
-
.
|
|
694
|
+
.connection
|
|
679
695
|
.clone()
|
|
680
696
|
.describe_namespace(
|
|
681
697
|
Namespace::Name(self.namespace.clone())
|
|
@@ -689,6 +705,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
689
705
|
async fn shutdown_worker(
|
|
690
706
|
&self,
|
|
691
707
|
sticky_task_queue: String,
|
|
708
|
+
task_queue: String,
|
|
709
|
+
task_queue_types: Vec<TaskQueueType>,
|
|
692
710
|
final_heartbeat: Option<WorkerHeartbeat>,
|
|
693
711
|
) -> Result<ShutdownWorkerResponse> {
|
|
694
712
|
let mut final_heartbeat = final_heartbeat;
|
|
@@ -697,10 +715,13 @@ impl WorkerClient for WorkerClientBag {
|
|
|
697
715
|
}
|
|
698
716
|
let mut request = ShutdownWorkerRequest {
|
|
699
717
|
namespace: self.namespace.clone(),
|
|
700
|
-
identity: self.identity
|
|
718
|
+
identity: self.identity(),
|
|
701
719
|
sticky_task_queue,
|
|
702
720
|
reason: "graceful shutdown".to_string(),
|
|
703
721
|
worker_heartbeat: final_heartbeat,
|
|
722
|
+
worker_instance_key: self.worker_instance_key.to_string(),
|
|
723
|
+
task_queue,
|
|
724
|
+
task_queue_types: task_queue_types.into_iter().map(|t| t as i32).collect(),
|
|
704
725
|
}
|
|
705
726
|
.into_request();
|
|
706
727
|
request
|
|
@@ -708,7 +729,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
708
729
|
.insert(RetryConfigForCall(RetryOptions::no_retries()));
|
|
709
730
|
|
|
710
731
|
Ok(
|
|
711
|
-
WorkflowService::shutdown_worker(&mut self.
|
|
732
|
+
WorkflowService::shutdown_worker(&mut self.connection.clone(), request)
|
|
712
733
|
.await?
|
|
713
734
|
.into_inner(),
|
|
714
735
|
)
|
|
@@ -721,32 +742,27 @@ impl WorkerClient for WorkerClientBag {
|
|
|
721
742
|
) -> Result<RecordWorkerHeartbeatResponse> {
|
|
722
743
|
let request = RecordWorkerHeartbeatRequest {
|
|
723
744
|
namespace,
|
|
724
|
-
identity: self.identity
|
|
745
|
+
identity: self.identity(),
|
|
725
746
|
worker_heartbeat,
|
|
726
747
|
};
|
|
727
748
|
Ok(self
|
|
728
|
-
.
|
|
749
|
+
.connection
|
|
729
750
|
.clone()
|
|
730
751
|
.record_worker_heartbeat(request.into_request())
|
|
731
752
|
.await?
|
|
732
753
|
.into_inner())
|
|
733
754
|
}
|
|
734
755
|
|
|
735
|
-
fn
|
|
736
|
-
self.
|
|
756
|
+
fn replace_connection(&self, new_connection: Connection) {
|
|
757
|
+
self.connection.replace_client(new_connection);
|
|
737
758
|
}
|
|
738
759
|
|
|
739
760
|
fn capabilities(&self) -> Option<Capabilities> {
|
|
740
|
-
self.
|
|
741
|
-
.get_client()
|
|
742
|
-
.inner_cow()
|
|
743
|
-
.inner()
|
|
744
|
-
.capabilities()
|
|
745
|
-
.cloned()
|
|
761
|
+
self.connection.inner_cow().capabilities().cloned()
|
|
746
762
|
}
|
|
747
763
|
|
|
748
764
|
fn workers(&self) -> Arc<ClientWorkerSet> {
|
|
749
|
-
self.
|
|
765
|
+
self.connection.inner_cow().workers()
|
|
750
766
|
}
|
|
751
767
|
|
|
752
768
|
fn is_mock(&self) -> bool {
|
|
@@ -754,17 +770,23 @@ impl WorkerClient for WorkerClientBag {
|
|
|
754
770
|
}
|
|
755
771
|
|
|
756
772
|
fn sdk_name_and_version(&self) -> (String, String) {
|
|
757
|
-
let inner = self.
|
|
758
|
-
|
|
759
|
-
|
|
773
|
+
let inner = self.connection.inner_cow();
|
|
774
|
+
(
|
|
775
|
+
inner.client_name().to_owned(),
|
|
776
|
+
inner.client_version().to_owned(),
|
|
777
|
+
)
|
|
760
778
|
}
|
|
761
779
|
|
|
762
780
|
fn identity(&self) -> String {
|
|
763
|
-
self.identity
|
|
781
|
+
self.identity()
|
|
764
782
|
}
|
|
765
783
|
|
|
766
784
|
fn worker_grouping_key(&self) -> Uuid {
|
|
767
|
-
self.
|
|
785
|
+
self.connection.inner_cow().worker_grouping_key()
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
fn worker_instance_key(&self) -> Uuid {
|
|
789
|
+
self.worker_instance_key
|
|
768
790
|
}
|
|
769
791
|
|
|
770
792
|
fn set_heartbeat_client_fields(&self, heartbeat: &mut WorkerHeartbeat) {
|
|
@@ -818,7 +840,7 @@ impl NamespacedClient for WorkerClientBag {
|
|
|
818
840
|
}
|
|
819
841
|
|
|
820
842
|
fn identity(&self) -> String {
|
|
821
|
-
self.identity
|
|
843
|
+
self.identity()
|
|
822
844
|
}
|
|
823
845
|
}
|
|
824
846
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
WorkerClient,
|
|
3
|
-
worker::{TaskPollers, WorkerTelemetry},
|
|
2
|
+
WorkerClient, WorkerConfig,
|
|
3
|
+
worker::{PollerBehavior, TaskPollers, WorkerTelemetry, WorkerVersioningStrategy},
|
|
4
4
|
};
|
|
5
5
|
use parking_lot::RwLock;
|
|
6
6
|
use std::{collections::HashMap, sync::Arc, time::Duration};
|
|
7
7
|
use temporalio_client::worker::SharedNamespaceWorkerTrait;
|
|
8
8
|
use temporalio_common::{
|
|
9
|
-
protos::temporal::api::worker::v1::WorkerHeartbeat,
|
|
10
|
-
worker::{PollerBehavior, WorkerConfig, WorkerTaskTypes, WorkerVersioningStrategy},
|
|
9
|
+
protos::temporal::api::worker::v1::WorkerHeartbeat, worker::WorkerTaskTypes,
|
|
11
10
|
};
|
|
12
11
|
use tokio::sync::Notify;
|
|
13
12
|
use tokio_util::sync::CancellationToken;
|
|
@@ -161,7 +160,7 @@ mod tests {
|
|
|
161
160
|
use crate::{
|
|
162
161
|
test_help::{WorkerExt, test_worker_cfg},
|
|
163
162
|
worker,
|
|
164
|
-
worker::client::mocks::mock_worker_client,
|
|
163
|
+
worker::{PollerBehavior, client::mocks::mock_worker_client},
|
|
165
164
|
};
|
|
166
165
|
use std::{
|
|
167
166
|
sync::{
|
|
@@ -170,12 +169,9 @@ mod tests {
|
|
|
170
169
|
},
|
|
171
170
|
time::Duration,
|
|
172
171
|
};
|
|
173
|
-
use temporalio_common::{
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
workflowservice::v1::{DescribeNamespaceResponse, RecordWorkerHeartbeatResponse},
|
|
177
|
-
},
|
|
178
|
-
worker::PollerBehavior,
|
|
172
|
+
use temporalio_common::protos::temporal::api::{
|
|
173
|
+
namespace::v1::{NamespaceInfo, namespace_info::Capabilities},
|
|
174
|
+
workflowservice::v1::{DescribeNamespaceResponse, RecordWorkerHeartbeatResponse},
|
|
179
175
|
};
|
|
180
176
|
|
|
181
177
|
#[tokio::test]
|