@temporalio/core-bridge 0.16.4 → 0.18.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.
- package/Cargo.lock +339 -226
- package/Cargo.toml +7 -3
- package/common.js +50 -0
- package/index.d.ts +7 -0
- package/index.js +12 -0
- package/package.json +7 -4
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/{index.node → releases/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/scripts/build.js +10 -50
- package/sdk-core/.buildkite/docker/Dockerfile +1 -1
- package/sdk-core/.buildkite/docker/docker-compose.yaml +2 -2
- package/sdk-core/.buildkite/pipeline.yml +2 -0
- package/sdk-core/Cargo.toml +1 -88
- package/sdk-core/README.md +30 -6
- package/sdk-core/bridge-ffi/Cargo.toml +24 -0
- package/sdk-core/bridge-ffi/LICENSE.txt +23 -0
- package/sdk-core/bridge-ffi/build.rs +25 -0
- package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +216 -0
- package/sdk-core/bridge-ffi/src/lib.rs +829 -0
- package/sdk-core/bridge-ffi/src/wrappers.rs +193 -0
- package/sdk-core/client/Cargo.toml +32 -0
- package/sdk-core/{src/pollers/gateway.rs → client/src/lib.rs} +101 -195
- package/sdk-core/client/src/metrics.rs +89 -0
- package/sdk-core/client/src/mocks.rs +167 -0
- package/sdk-core/{src/pollers → client/src}/retry.rs +172 -14
- package/sdk-core/core/Cargo.toml +96 -0
- package/sdk-core/{src → core/src}/core_tests/activity_tasks.rs +193 -37
- package/sdk-core/{src → core/src}/core_tests/child_workflows.rs +14 -14
- package/sdk-core/{src → core/src}/core_tests/determinism.rs +8 -8
- package/sdk-core/core/src/core_tests/local_activities.rs +328 -0
- package/sdk-core/{src → core/src}/core_tests/mod.rs +6 -9
- package/sdk-core/{src → core/src}/core_tests/queries.rs +54 -54
- package/sdk-core/{src → core/src}/core_tests/replay_flag.rs +8 -12
- package/sdk-core/{src → core/src}/core_tests/workers.rs +120 -33
- package/sdk-core/{src → core/src}/core_tests/workflow_cancels.rs +16 -26
- package/sdk-core/{src → core/src}/core_tests/workflow_tasks.rs +280 -292
- package/sdk-core/core/src/lib.rs +374 -0
- package/sdk-core/{src → core/src}/log_export.rs +3 -27
- package/sdk-core/core/src/pending_activations.rs +162 -0
- package/sdk-core/{src → core/src}/pollers/mod.rs +4 -22
- package/sdk-core/{src → core/src}/pollers/poll_buffer.rs +1 -1
- package/sdk-core/core/src/protosext/mod.rs +396 -0
- package/sdk-core/core/src/replay/mod.rs +210 -0
- package/sdk-core/core/src/retry_logic.rs +144 -0
- package/sdk-core/{src → core/src}/telemetry/metrics.rs +3 -58
- package/sdk-core/{src → core/src}/telemetry/mod.rs +8 -8
- package/sdk-core/{src → core/src}/telemetry/prometheus_server.rs +0 -0
- package/sdk-core/{src → core/src}/test_help/mod.rs +35 -83
- package/sdk-core/{src → core/src}/worker/activities/activity_heartbeat_manager.rs +95 -42
- package/sdk-core/core/src/worker/activities/local_activities.rs +973 -0
- package/sdk-core/{src → core/src}/worker/activities.rs +52 -33
- package/sdk-core/{src → core/src}/worker/dispatcher.rs +8 -6
- package/sdk-core/{src → core/src}/worker/mod.rs +347 -221
- package/sdk-core/core/src/worker/wft_delivery.rs +81 -0
- package/sdk-core/{src → core/src}/workflow/bridge.rs +5 -2
- package/sdk-core/{src → core/src}/workflow/driven_workflow.rs +17 -7
- package/sdk-core/{src → core/src}/workflow/history_update.rs +33 -7
- package/sdk-core/{src → core/src/workflow}/machines/activity_state_machine.rs +26 -26
- package/sdk-core/{src → core/src/workflow}/machines/cancel_external_state_machine.rs +8 -11
- package/sdk-core/{src → core/src/workflow}/machines/cancel_workflow_state_machine.rs +19 -21
- package/sdk-core/{src → core/src/workflow}/machines/child_workflow_state_machine.rs +20 -31
- package/sdk-core/{src → core/src/workflow}/machines/complete_workflow_state_machine.rs +3 -5
- package/sdk-core/{src → core/src/workflow}/machines/continue_as_new_workflow_state_machine.rs +18 -18
- package/sdk-core/{src → core/src/workflow}/machines/fail_workflow_state_machine.rs +5 -6
- package/sdk-core/core/src/workflow/machines/local_activity_state_machine.rs +1451 -0
- package/sdk-core/{src → core/src/workflow}/machines/mod.rs +54 -107
- package/sdk-core/{src → core/src/workflow}/machines/mutable_side_effect_state_machine.rs +0 -0
- package/sdk-core/{src → core/src/workflow}/machines/patch_state_machine.rs +29 -30
- package/sdk-core/{src → core/src/workflow}/machines/side_effect_state_machine.rs +0 -0
- package/sdk-core/{src → core/src/workflow}/machines/signal_external_state_machine.rs +17 -19
- package/sdk-core/{src → core/src/workflow}/machines/timer_state_machine.rs +20 -21
- package/sdk-core/{src → core/src/workflow}/machines/transition_coverage.rs +5 -2
- package/sdk-core/{src → core/src/workflow}/machines/upsert_search_attributes_state_machine.rs +0 -0
- package/sdk-core/core/src/workflow/machines/workflow_machines/local_acts.rs +96 -0
- package/sdk-core/{src → core/src/workflow}/machines/workflow_machines.rs +357 -171
- package/sdk-core/{src → core/src/workflow}/machines/workflow_task_state_machine.rs +1 -1
- package/sdk-core/{src → core/src}/workflow/mod.rs +200 -39
- package/sdk-core/{src → core/src}/workflow/workflow_tasks/cache_manager.rs +0 -0
- package/sdk-core/{src → core/src}/workflow/workflow_tasks/concurrency_manager.rs +38 -5
- package/sdk-core/{src → core/src}/workflow/workflow_tasks/mod.rs +317 -103
- package/sdk-core/{test_utils → core-api}/Cargo.toml +10 -7
- package/sdk-core/{src → core-api/src}/errors.rs +42 -92
- package/sdk-core/core-api/src/lib.rs +158 -0
- package/sdk-core/{src/worker/config.rs → core-api/src/worker.rs} +18 -23
- package/sdk-core/etc/deps.svg +156 -0
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +5 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +3 -5
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +7 -1
- package/sdk-core/histories/fail_wf_task.bin +0 -0
- package/sdk-core/histories/timer_workflow_history.bin +0 -0
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +44 -13
- package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +19 -1
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +1 -1
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +9 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +1 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +1 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +13 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +14 -7
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +176 -18
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -0
- package/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +11 -0
- package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +156 -7
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +135 -104
- package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +78 -0
- package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +78 -0
- package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +205 -0
- package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +61 -0
- package/sdk-core/protos/local/{child_workflow.proto → temporal/sdk/core/child_workflow/child_workflow.proto} +1 -1
- package/sdk-core/protos/local/{common.proto → temporal/sdk/core/common/common.proto} +5 -3
- package/sdk-core/protos/local/{core_interface.proto → temporal/sdk/core/core_interface.proto} +10 -10
- package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +30 -0
- package/sdk-core/protos/local/{workflow_activation.proto → temporal/sdk/core/workflow_activation/workflow_activation.proto} +35 -11
- package/sdk-core/protos/local/{workflow_commands.proto → temporal/sdk/core/workflow_commands/workflow_commands.proto} +55 -4
- package/sdk-core/protos/local/{workflow_completion.proto → temporal/sdk/core/workflow_completion/workflow_completion.proto} +3 -3
- package/sdk-core/sdk/Cargo.toml +32 -0
- package/sdk-core/{src/prototype_rust_sdk → sdk/src}/conversions.rs +0 -0
- package/sdk-core/sdk/src/lib.rs +699 -0
- package/sdk-core/sdk/src/payload_converter.rs +11 -0
- package/sdk-core/sdk/src/workflow_context/options.rs +180 -0
- package/sdk-core/{src/prototype_rust_sdk → sdk/src}/workflow_context.rs +201 -124
- package/sdk-core/{src/prototype_rust_sdk → sdk/src}/workflow_future.rs +63 -30
- package/sdk-core/sdk-core-protos/Cargo.toml +10 -0
- package/sdk-core/sdk-core-protos/build.rs +28 -6
- package/sdk-core/sdk-core-protos/src/constants.rs +7 -0
- package/sdk-core/{src/test_help → sdk-core-protos/src}/history_builder.rs +134 -49
- package/sdk-core/sdk-core-protos/src/history_info.rs +216 -0
- package/sdk-core/sdk-core-protos/src/lib.rs +601 -168
- package/sdk-core/sdk-core-protos/src/task_token.rs +38 -0
- package/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
- package/sdk-core/test-utils/Cargo.toml +32 -0
- package/sdk-core/{src/test_help → test-utils/src}/canned_histories.rs +59 -78
- package/sdk-core/test-utils/src/histfetch.rs +28 -0
- package/sdk-core/{test_utils → test-utils}/src/lib.rs +131 -68
- package/sdk-core/tests/integ_tests/client_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +11 -7
- package/sdk-core/tests/integ_tests/polling_tests.rs +12 -11
- package/sdk-core/tests/integ_tests/queries_tests.rs +82 -78
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +91 -71
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +3 -4
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +2 -4
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +4 -6
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +4 -6
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -4
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +496 -0
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +5 -8
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +125 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +7 -13
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +33 -5
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +12 -16
- package/sdk-core/tests/integ_tests/workflow_tests.rs +85 -82
- package/sdk-core/tests/load_tests.rs +6 -6
- package/sdk-core/tests/main.rs +2 -2
- package/src/conversions.rs +24 -21
- package/src/errors.rs +8 -0
- package/src/lib.rs +323 -211
- package/sdk-core/protos/local/activity_result.proto +0 -46
- package/sdk-core/protos/local/activity_task.proto +0 -66
- package/sdk-core/src/core_tests/retry.rs +0 -147
- package/sdk-core/src/lib.rs +0 -403
- package/sdk-core/src/machines/local_activity_state_machine.rs +0 -117
- package/sdk-core/src/pending_activations.rs +0 -249
- package/sdk-core/src/protosext/mod.rs +0 -160
- package/sdk-core/src/prototype_rust_sdk.rs +0 -412
- package/sdk-core/src/task_token.rs +0 -20
- package/sdk-core/src/test_help/history_info.rs +0 -157
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
mod activity_heartbeat_manager;
|
|
2
|
+
mod local_activities;
|
|
3
|
+
|
|
4
|
+
pub(crate) use local_activities::{
|
|
5
|
+
DispatchOrTimeoutLA, ExecutingLAId, LACompleteAction, LocalActRequest,
|
|
6
|
+
LocalActivityExecutionResult, LocalActivityManager, LocalActivityResolution,
|
|
7
|
+
LocalInFlightActInfo, NewLocalAct,
|
|
8
|
+
};
|
|
2
9
|
|
|
3
10
|
use crate::{
|
|
4
11
|
pollers::BoxedActPoller,
|
|
5
|
-
task_token::TaskToken,
|
|
6
12
|
telemetry::metrics::{activity_type, workflow_type, MetricsContext},
|
|
7
|
-
ActivityHeartbeatError,
|
|
13
|
+
worker::activities::activity_heartbeat_manager::ActivityHeartbeatError,
|
|
14
|
+
CompleteActivityError, PollActivityError, ServerGatewayApis, TaskToken,
|
|
8
15
|
};
|
|
9
16
|
use activity_heartbeat_manager::ActivityHeartbeatManager;
|
|
10
17
|
use dashmap::DashMap;
|
|
@@ -15,7 +22,7 @@ use std::{
|
|
|
15
22
|
};
|
|
16
23
|
use temporal_sdk_core_protos::{
|
|
17
24
|
coresdk::{
|
|
18
|
-
activity_result::{self as ar,
|
|
25
|
+
activity_result::{self as ar, activity_execution_result as aer},
|
|
19
26
|
activity_task::{ActivityCancelReason, ActivityTask},
|
|
20
27
|
ActivityHeartbeat,
|
|
21
28
|
},
|
|
@@ -24,7 +31,7 @@ use temporal_sdk_core_protos::{
|
|
|
24
31
|
workflowservice::v1::PollActivityTaskQueueResponse,
|
|
25
32
|
},
|
|
26
33
|
};
|
|
27
|
-
use tokio::sync::Semaphore;
|
|
34
|
+
use tokio::sync::{Notify, Semaphore};
|
|
28
35
|
|
|
29
36
|
#[derive(Debug, derive_more::Constructor)]
|
|
30
37
|
struct PendingActivityCancel {
|
|
@@ -32,12 +39,18 @@ struct PendingActivityCancel {
|
|
|
32
39
|
reason: ActivityCancelReason,
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
/// Contains minimal set of details that core needs to store
|
|
42
|
+
/// Contains minimal set of details that core needs to store while an activity is running.
|
|
36
43
|
#[derive(Debug)]
|
|
37
|
-
struct
|
|
38
|
-
pub activity_id: String,
|
|
44
|
+
struct InFlightActInfo {
|
|
39
45
|
pub activity_type: String,
|
|
40
46
|
pub workflow_type: String,
|
|
47
|
+
start_time: Instant,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// Augments [InFlightActInfo] with details specific to remote activities
|
|
51
|
+
#[derive(Debug)]
|
|
52
|
+
struct RemoteInFlightActInfo {
|
|
53
|
+
pub base: InFlightActInfo,
|
|
41
54
|
/// Used to calculate aggregation delay between activity heartbeats.
|
|
42
55
|
pub heartbeat_timeout: Option<prost_types::Duration>,
|
|
43
56
|
/// Set to true if we have already issued a cancellation activation to lang for this activity
|
|
@@ -46,23 +59,22 @@ struct InflightActivityDetails {
|
|
|
46
59
|
/// we have learned from heartbeating and issued a cancel task, in which case we may simply
|
|
47
60
|
/// discard the reply.
|
|
48
61
|
pub known_not_found: bool,
|
|
49
|
-
start_time: Instant,
|
|
50
62
|
}
|
|
51
|
-
impl
|
|
63
|
+
impl RemoteInFlightActInfo {
|
|
52
64
|
fn new(
|
|
53
|
-
activity_id: String,
|
|
54
65
|
activity_type: String,
|
|
55
66
|
workflow_type: String,
|
|
56
67
|
heartbeat_timeout: Option<prost_types::Duration>,
|
|
57
68
|
) -> Self {
|
|
58
69
|
Self {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
base: InFlightActInfo {
|
|
71
|
+
activity_type,
|
|
72
|
+
workflow_type,
|
|
73
|
+
start_time: Instant::now(),
|
|
74
|
+
},
|
|
62
75
|
heartbeat_timeout,
|
|
63
76
|
issued_cancel_to_lang: false,
|
|
64
77
|
known_not_found: false,
|
|
65
|
-
start_time: Instant::now(),
|
|
66
78
|
}
|
|
67
79
|
}
|
|
68
80
|
}
|
|
@@ -71,12 +83,14 @@ pub(crate) struct WorkerActivityTasks {
|
|
|
71
83
|
/// Centralizes management of heartbeat issuing / throttling
|
|
72
84
|
heartbeat_manager: ActivityHeartbeatManager,
|
|
73
85
|
/// Activities that have been issued to lang but not yet completed
|
|
74
|
-
outstanding_activity_tasks: DashMap<TaskToken,
|
|
86
|
+
outstanding_activity_tasks: DashMap<TaskToken, RemoteInFlightActInfo>,
|
|
75
87
|
/// Buffers activity task polling in the event we need to return a cancellation while a poll is
|
|
76
88
|
/// ongoing.
|
|
77
89
|
poller: BoxedActPoller,
|
|
78
90
|
/// Ensures we stay at or below this worker's maximum concurrent activity limit
|
|
79
91
|
activities_semaphore: Semaphore,
|
|
92
|
+
/// Wakes every time an activity is removed from the outstanding map
|
|
93
|
+
complete_notify: Notify,
|
|
80
94
|
|
|
81
95
|
metrics: MetricsContext,
|
|
82
96
|
|
|
@@ -98,6 +112,7 @@ impl WorkerActivityTasks {
|
|
|
98
112
|
outstanding_activity_tasks: Default::default(),
|
|
99
113
|
poller,
|
|
100
114
|
activities_semaphore: Semaphore::new(max_activity_tasks),
|
|
115
|
+
complete_notify: Notify::new(),
|
|
101
116
|
metrics,
|
|
102
117
|
max_heartbeat_throttle_interval,
|
|
103
118
|
default_heartbeat_throttle_interval,
|
|
@@ -108,13 +123,21 @@ impl WorkerActivityTasks {
|
|
|
108
123
|
self.poller.notify_shutdown();
|
|
109
124
|
}
|
|
110
125
|
|
|
126
|
+
/// Wait for all outstanding activity tasks to finish
|
|
127
|
+
pub(crate) async fn wait_all_finished(&self) {
|
|
128
|
+
while !self.outstanding_activity_tasks.is_empty() {
|
|
129
|
+
self.complete_notify.notified().await
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
111
133
|
pub(crate) async fn shutdown(self) {
|
|
112
134
|
self.poller.shutdown_box().await;
|
|
113
135
|
self.heartbeat_manager.shutdown().await;
|
|
114
136
|
}
|
|
115
137
|
|
|
116
|
-
///
|
|
117
|
-
///
|
|
138
|
+
/// Wait until not at the outstanding activity limit, and then poll for an activity task.
|
|
139
|
+
///
|
|
140
|
+
/// Returns `Ok(None)` if no activity is ready and the overall polling loop should be retried.
|
|
118
141
|
pub(crate) async fn poll(&self) -> Result<Option<ActivityTask>, PollActivityError> {
|
|
119
142
|
let poll_with_semaphore = async {
|
|
120
143
|
// Acquire and subsequently forget a permit for an outstanding activity. When they are
|
|
@@ -150,8 +173,7 @@ impl WorkerActivityTasks {
|
|
|
150
173
|
|
|
151
174
|
self.outstanding_activity_tasks.insert(
|
|
152
175
|
work.task_token.clone().into(),
|
|
153
|
-
|
|
154
|
-
work.activity_id.clone(),
|
|
176
|
+
RemoteInFlightActInfo::new(
|
|
155
177
|
work.activity_type.clone().unwrap_or_default().name,
|
|
156
178
|
work.workflow_type.clone().unwrap_or_default().name,
|
|
157
179
|
work.heartbeat_timeout.clone()
|
|
@@ -173,36 +195,37 @@ impl WorkerActivityTasks {
|
|
|
173
195
|
pub(crate) async fn complete(
|
|
174
196
|
&self,
|
|
175
197
|
task_token: TaskToken,
|
|
176
|
-
status:
|
|
198
|
+
status: aer::Status,
|
|
177
199
|
gateway: &(dyn ServerGatewayApis + Send + Sync),
|
|
178
200
|
) -> Result<(), CompleteActivityError> {
|
|
179
201
|
if let Some((_, act_info)) = self.outstanding_activity_tasks.remove(&task_token) {
|
|
180
202
|
let act_metrics = self.metrics.with_new_attrs([
|
|
181
|
-
activity_type(act_info.activity_type.clone()),
|
|
182
|
-
workflow_type(act_info.workflow_type.clone()),
|
|
203
|
+
activity_type(act_info.base.activity_type.clone()),
|
|
204
|
+
workflow_type(act_info.base.workflow_type.clone()),
|
|
183
205
|
]);
|
|
184
|
-
act_metrics.act_execution_latency(act_info.start_time.elapsed());
|
|
206
|
+
act_metrics.act_execution_latency(act_info.base.start_time.elapsed());
|
|
185
207
|
self.activities_semaphore.add_permits(1);
|
|
186
|
-
self.heartbeat_manager.evict(task_token.clone());
|
|
208
|
+
self.heartbeat_manager.evict(task_token.clone()).await;
|
|
187
209
|
let known_not_found = act_info.known_not_found;
|
|
188
210
|
drop(act_info); // TODO: Get rid of dashmap. If we hold ref across await, bad stuff.
|
|
211
|
+
self.complete_notify.notify_waiters();
|
|
189
212
|
|
|
190
213
|
// No need to report activities which we already know the server doesn't care about
|
|
191
214
|
if !known_not_found {
|
|
192
215
|
let maybe_net_err = match status {
|
|
193
|
-
|
|
194
|
-
|
|
216
|
+
aer::Status::WillCompleteAsync(_) => None,
|
|
217
|
+
aer::Status::Completed(ar::Success { result }) => gateway
|
|
195
218
|
.complete_activity_task(task_token.clone(), result.map(Into::into))
|
|
196
219
|
.await
|
|
197
220
|
.err(),
|
|
198
|
-
|
|
221
|
+
aer::Status::Failed(ar::Failure { failure }) => {
|
|
199
222
|
act_metrics.act_execution_failed();
|
|
200
223
|
gateway
|
|
201
224
|
.fail_activity_task(task_token.clone(), failure.map(Into::into))
|
|
202
225
|
.await
|
|
203
226
|
.err()
|
|
204
227
|
}
|
|
205
|
-
|
|
228
|
+
aer::Status::Cancelled(ar::Cancellation { failure }) => {
|
|
206
229
|
let details = if let Some(Failure {
|
|
207
230
|
failure_info:
|
|
208
231
|
Some(FailureInfo::CanceledFailureInfo(CanceledFailureInfo { details })),
|
|
@@ -291,11 +314,7 @@ impl WorkerActivityTasks {
|
|
|
291
314
|
if reason == ActivityCancelReason::NotFound {
|
|
292
315
|
details.known_not_found = true;
|
|
293
316
|
}
|
|
294
|
-
Ok(Some(ActivityTask::cancel_from_ids(
|
|
295
|
-
task_token.0,
|
|
296
|
-
details.activity_id.clone(),
|
|
297
|
-
reason,
|
|
298
|
-
)))
|
|
317
|
+
Ok(Some(ActivityTask::cancel_from_ids(task_token.0, reason)))
|
|
299
318
|
} else {
|
|
300
319
|
warn!(task_token = ?task_token,
|
|
301
320
|
"Unknown activity task when issuing cancel");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
pollers::GatewayRef,
|
|
3
2
|
telemetry::metrics::{task_queue, MetricsContext},
|
|
4
3
|
worker::Worker,
|
|
5
4
|
WorkerConfig, WorkerLookupErr, WorkerRegistrationError,
|
|
@@ -7,6 +6,7 @@ use crate::{
|
|
|
7
6
|
use arc_swap::ArcSwap;
|
|
8
7
|
use futures::future::join_all;
|
|
9
8
|
use std::{collections::HashMap, ops::Deref, option::Option, sync::Arc};
|
|
9
|
+
use temporal_client::ServerGatewayApis;
|
|
10
10
|
use tokio::sync::Notify;
|
|
11
11
|
|
|
12
12
|
/// Allows access to workers by task queue name
|
|
@@ -18,11 +18,11 @@ pub(crate) struct WorkerDispatcher {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
impl WorkerDispatcher {
|
|
21
|
-
pub
|
|
21
|
+
pub fn new_worker(
|
|
22
22
|
&self,
|
|
23
23
|
config: WorkerConfig,
|
|
24
24
|
sticky_queue: Option<String>,
|
|
25
|
-
gateway: Arc<
|
|
25
|
+
gateway: Arc<dyn ServerGatewayApis + Send + Sync>,
|
|
26
26
|
parent_metrics: MetricsContext,
|
|
27
27
|
) -> Result<(), WorkerRegistrationError> {
|
|
28
28
|
let tq = config.task_queue.clone();
|
|
@@ -96,13 +96,15 @@ impl WorkerDispatcher {
|
|
|
96
96
|
}))
|
|
97
97
|
.await;
|
|
98
98
|
|
|
99
|
-
let mut all_workers =
|
|
99
|
+
let mut all_workers = vec![];
|
|
100
100
|
self.workers.rcu(|map| {
|
|
101
101
|
let mut map = HashMap::clone(map);
|
|
102
|
-
|
|
102
|
+
for worker in map.values_mut() {
|
|
103
|
+
all_workers.push(worker.take());
|
|
104
|
+
}
|
|
103
105
|
map
|
|
104
106
|
});
|
|
105
|
-
join_all(all_workers.
|
|
107
|
+
join_all(all_workers.into_iter().map(|w| async move {
|
|
106
108
|
if let Some(w) = w {
|
|
107
109
|
w.destroy().await;
|
|
108
110
|
}
|