@temporalio/core-bridge 0.19.2 → 0.20.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 +90 -157
- package/Cargo.toml +1 -0
- package/index.d.ts +11 -27
- package/package.json +3 -3
- 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/.buildkite/docker/Dockerfile +1 -1
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.cargo/config.toml +1 -0
- package/sdk-core/CODEOWNERS +1 -1
- package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +119 -86
- package/sdk-core/bridge-ffi/src/lib.rs +311 -315
- package/sdk-core/bridge-ffi/src/wrappers.rs +108 -113
- package/sdk-core/client/Cargo.toml +13 -9
- package/sdk-core/client/LICENSE.txt +23 -0
- package/sdk-core/client/src/lib.rs +286 -174
- package/sdk-core/client/src/metrics.rs +86 -12
- package/sdk-core/client/src/raw.rs +566 -0
- package/sdk-core/client/src/retry.rs +137 -99
- package/sdk-core/core/Cargo.toml +15 -10
- package/sdk-core/core/LICENSE.txt +23 -0
- package/sdk-core/core/benches/workflow_replay.rs +79 -0
- package/sdk-core/core/src/abstractions.rs +38 -0
- package/sdk-core/core/src/core_tests/activity_tasks.rs +108 -182
- package/sdk-core/core/src/core_tests/child_workflows.rs +16 -11
- package/sdk-core/core/src/core_tests/determinism.rs +24 -12
- package/sdk-core/core/src/core_tests/local_activities.rs +53 -27
- package/sdk-core/core/src/core_tests/mod.rs +30 -43
- package/sdk-core/core/src/core_tests/queries.rs +82 -81
- package/sdk-core/core/src/core_tests/workers.rs +111 -296
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +4 -4
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +213 -241
- package/sdk-core/core/src/lib.rs +73 -318
- package/sdk-core/core/src/pollers/mod.rs +4 -6
- package/sdk-core/core/src/pollers/poll_buffer.rs +20 -14
- package/sdk-core/core/src/protosext/mod.rs +7 -10
- package/sdk-core/core/src/replay/mod.rs +11 -150
- package/sdk-core/core/src/telemetry/metrics.rs +35 -2
- package/sdk-core/core/src/telemetry/mod.rs +49 -16
- package/sdk-core/core/src/telemetry/prometheus_server.rs +14 -35
- package/sdk-core/core/src/test_help/mod.rs +104 -170
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +57 -34
- package/sdk-core/core/src/worker/activities/local_activities.rs +37 -17
- package/sdk-core/core/src/worker/activities.rs +23 -16
- package/sdk-core/core/src/worker/client/mocks.rs +86 -0
- package/sdk-core/core/src/worker/client.rs +209 -0
- package/sdk-core/core/src/worker/mod.rs +193 -105
- package/sdk-core/core/src/workflow/driven_workflow.rs +21 -6
- package/sdk-core/core/src/workflow/history_update.rs +107 -24
- package/sdk-core/core/src/workflow/machines/activity_state_machine.rs +2 -3
- package/sdk-core/core/src/workflow/machines/child_workflow_state_machine.rs +2 -3
- package/sdk-core/core/src/workflow/machines/mod.rs +20 -17
- package/sdk-core/core/src/workflow/machines/signal_external_state_machine.rs +56 -19
- package/sdk-core/core/src/workflow/machines/transition_coverage.rs +5 -0
- package/sdk-core/core/src/workflow/machines/upsert_search_attributes_state_machine.rs +230 -22
- package/sdk-core/core/src/workflow/machines/workflow_machines.rs +81 -115
- package/sdk-core/core/src/workflow/machines/workflow_task_state_machine.rs +4 -4
- package/sdk-core/core/src/workflow/mod.rs +13 -1
- package/sdk-core/core/src/workflow/workflow_tasks/mod.rs +43 -33
- package/sdk-core/core-api/Cargo.toml +9 -1
- package/sdk-core/core-api/LICENSE.txt +23 -0
- package/sdk-core/core-api/src/errors.rs +7 -38
- package/sdk-core/core-api/src/lib.rs +44 -52
- package/sdk-core/core-api/src/worker.rs +10 -2
- package/sdk-core/etc/deps.svg +127 -96
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +11 -7
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +10 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +6 -1
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +6 -0
- package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +6 -0
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +2 -1
- package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +12 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +25 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +4 -0
- package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +19 -35
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +2 -6
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +53 -11
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +14 -7
- package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +3 -5
- package/sdk-core/sdk/Cargo.toml +16 -2
- package/sdk-core/sdk/LICENSE.txt +23 -0
- package/sdk-core/sdk/src/interceptors.rs +11 -0
- package/sdk-core/sdk/src/lib.rs +138 -150
- package/sdk-core/sdk/src/workflow_context/options.rs +86 -1
- package/sdk-core/sdk/src/workflow_context.rs +36 -17
- package/sdk-core/sdk/src/workflow_future.rs +19 -25
- package/sdk-core/sdk-core-protos/Cargo.toml +1 -1
- package/sdk-core/sdk-core-protos/build.rs +1 -0
- package/sdk-core/sdk-core-protos/src/history_info.rs +17 -4
- package/sdk-core/sdk-core-protos/src/lib.rs +251 -47
- package/sdk-core/test-utils/Cargo.toml +3 -1
- package/sdk-core/test-utils/src/canned_histories.rs +27 -0
- package/sdk-core/test-utils/src/histfetch.rs +3 -3
- package/sdk-core/test-utils/src/lib.rs +223 -68
- package/sdk-core/tests/integ_tests/client_tests.rs +27 -4
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +93 -14
- package/sdk-core/tests/integ_tests/polling_tests.rs +18 -12
- package/sdk-core/tests/integ_tests/queries_tests.rs +50 -53
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +117 -103
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +8 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +10 -5
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +8 -3
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +76 -15
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +19 -3
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +39 -42
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +84 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +30 -8
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +21 -6
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +26 -16
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +66 -0
- package/sdk-core/tests/integ_tests/workflow_tests.rs +78 -74
- package/sdk-core/tests/load_tests.rs +9 -6
- package/sdk-core/tests/main.rs +43 -10
- package/src/conversions.rs +7 -12
- package/src/lib.rs +322 -357
- package/sdk-core/client/src/mocks.rs +0 -167
- package/sdk-core/core/src/worker/dispatcher.rs +0 -171
- package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +0 -61
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
//! Worker-specific client needs
|
|
2
|
+
|
|
3
|
+
pub(crate) mod mocks;
|
|
4
|
+
|
|
5
|
+
use std::{
|
|
6
|
+
borrow::Borrow,
|
|
7
|
+
ops::{Deref, DerefMut},
|
|
8
|
+
};
|
|
9
|
+
use temporal_client::{WorkflowClientTrait, WorkflowTaskCompletion};
|
|
10
|
+
use temporal_sdk_core_protos::{
|
|
11
|
+
coresdk::workflow_commands::QueryResult,
|
|
12
|
+
temporal::api::{
|
|
13
|
+
common::v1::Payloads, enums::v1::WorkflowTaskFailedCause, failure::v1::Failure,
|
|
14
|
+
workflowservice::v1::*,
|
|
15
|
+
},
|
|
16
|
+
TaskToken,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type Result<T, E = tonic::Status> = std::result::Result<T, E>;
|
|
20
|
+
|
|
21
|
+
/// Contains everything a worker needs to interact with the server
|
|
22
|
+
pub(crate) struct WorkerClientBag {
|
|
23
|
+
client: Box<dyn WorkerClient>,
|
|
24
|
+
namespace: String,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
impl WorkerClientBag {
|
|
28
|
+
pub fn new(client: Box<dyn WorkerClient>, namespace: String) -> Self {
|
|
29
|
+
Self { client, namespace }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
pub fn namespace(&self) -> &str {
|
|
33
|
+
&self.namespace
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
impl Deref for WorkerClientBag {
|
|
37
|
+
type Target = dyn WorkerClient;
|
|
38
|
+
|
|
39
|
+
fn deref(&self) -> &Self::Target {
|
|
40
|
+
&*self.client
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
impl DerefMut for WorkerClientBag {
|
|
44
|
+
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
45
|
+
&mut *self.client
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
#[cfg(test)]
|
|
49
|
+
impl<T> From<T> for WorkerClientBag
|
|
50
|
+
where
|
|
51
|
+
T: WorkerClient + 'static,
|
|
52
|
+
{
|
|
53
|
+
fn from(c: T) -> Self {
|
|
54
|
+
use temporal_sdk_core_test_utils::NAMESPACE;
|
|
55
|
+
|
|
56
|
+
WorkerClientBag::new(Box::new(c), NAMESPACE.to_string())
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// This trait contains everything workers need to interact with Temporal, and hence provides a
|
|
61
|
+
/// minimal mocking surface. Delegates to [WorkflowClientTrait] so see that for details.
|
|
62
|
+
#[cfg_attr(test, mockall::automock)]
|
|
63
|
+
#[async_trait::async_trait]
|
|
64
|
+
pub(crate) trait WorkerClient: Sync + Send {
|
|
65
|
+
async fn poll_workflow_task(
|
|
66
|
+
&self,
|
|
67
|
+
task_queue: String,
|
|
68
|
+
is_sticky: bool,
|
|
69
|
+
) -> Result<PollWorkflowTaskQueueResponse>;
|
|
70
|
+
async fn poll_activity_task(
|
|
71
|
+
&self,
|
|
72
|
+
task_queue: String,
|
|
73
|
+
max_tasks_per_sec: Option<f64>,
|
|
74
|
+
) -> Result<PollActivityTaskQueueResponse>;
|
|
75
|
+
async fn complete_workflow_task(
|
|
76
|
+
&self,
|
|
77
|
+
request: WorkflowTaskCompletion,
|
|
78
|
+
) -> Result<RespondWorkflowTaskCompletedResponse>;
|
|
79
|
+
async fn complete_activity_task(
|
|
80
|
+
&self,
|
|
81
|
+
task_token: TaskToken,
|
|
82
|
+
result: Option<Payloads>,
|
|
83
|
+
) -> Result<RespondActivityTaskCompletedResponse>;
|
|
84
|
+
async fn record_activity_heartbeat(
|
|
85
|
+
&self,
|
|
86
|
+
task_token: TaskToken,
|
|
87
|
+
details: Option<Payloads>,
|
|
88
|
+
) -> Result<RecordActivityTaskHeartbeatResponse>;
|
|
89
|
+
async fn cancel_activity_task(
|
|
90
|
+
&self,
|
|
91
|
+
task_token: TaskToken,
|
|
92
|
+
details: Option<Payloads>,
|
|
93
|
+
) -> Result<RespondActivityTaskCanceledResponse>;
|
|
94
|
+
async fn fail_activity_task(
|
|
95
|
+
&self,
|
|
96
|
+
task_token: TaskToken,
|
|
97
|
+
failure: Option<Failure>,
|
|
98
|
+
) -> Result<RespondActivityTaskFailedResponse>;
|
|
99
|
+
async fn fail_workflow_task(
|
|
100
|
+
&self,
|
|
101
|
+
task_token: TaskToken,
|
|
102
|
+
cause: WorkflowTaskFailedCause,
|
|
103
|
+
failure: Option<Failure>,
|
|
104
|
+
) -> Result<RespondWorkflowTaskFailedResponse>;
|
|
105
|
+
async fn get_workflow_execution_history(
|
|
106
|
+
&self,
|
|
107
|
+
workflow_id: String,
|
|
108
|
+
run_id: Option<String>,
|
|
109
|
+
page_token: Vec<u8>,
|
|
110
|
+
) -> Result<GetWorkflowExecutionHistoryResponse>;
|
|
111
|
+
async fn respond_legacy_query(
|
|
112
|
+
&self,
|
|
113
|
+
task_token: TaskToken,
|
|
114
|
+
query_result: QueryResult,
|
|
115
|
+
) -> Result<RespondQueryTaskCompletedResponse>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#[async_trait::async_trait]
|
|
119
|
+
impl<'a, T> WorkerClient for T
|
|
120
|
+
where
|
|
121
|
+
T: Borrow<dyn WorkflowClientTrait + 'a + Send + Sync> + Send + Sync,
|
|
122
|
+
{
|
|
123
|
+
async fn poll_workflow_task(
|
|
124
|
+
&self,
|
|
125
|
+
task_queue: String,
|
|
126
|
+
is_sticky: bool,
|
|
127
|
+
) -> Result<PollWorkflowTaskQueueResponse> {
|
|
128
|
+
WorkflowClientTrait::poll_workflow_task(self.borrow(), task_queue, is_sticky).await
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async fn poll_activity_task(
|
|
132
|
+
&self,
|
|
133
|
+
task_queue: String,
|
|
134
|
+
max_tasks_per_sec: Option<f64>,
|
|
135
|
+
) -> Result<PollActivityTaskQueueResponse> {
|
|
136
|
+
WorkflowClientTrait::poll_activity_task(self.borrow(), task_queue, max_tasks_per_sec).await
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async fn complete_workflow_task(
|
|
140
|
+
&self,
|
|
141
|
+
request: WorkflowTaskCompletion,
|
|
142
|
+
) -> Result<RespondWorkflowTaskCompletedResponse> {
|
|
143
|
+
WorkflowClientTrait::complete_workflow_task(self.borrow(), request).await
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async fn complete_activity_task(
|
|
147
|
+
&self,
|
|
148
|
+
task_token: TaskToken,
|
|
149
|
+
result: Option<Payloads>,
|
|
150
|
+
) -> Result<RespondActivityTaskCompletedResponse> {
|
|
151
|
+
WorkflowClientTrait::complete_activity_task(self.borrow(), task_token, result).await
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async fn record_activity_heartbeat(
|
|
155
|
+
&self,
|
|
156
|
+
task_token: TaskToken,
|
|
157
|
+
details: Option<Payloads>,
|
|
158
|
+
) -> Result<RecordActivityTaskHeartbeatResponse> {
|
|
159
|
+
WorkflowClientTrait::record_activity_heartbeat(self.borrow(), task_token, details).await
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async fn cancel_activity_task(
|
|
163
|
+
&self,
|
|
164
|
+
task_token: TaskToken,
|
|
165
|
+
details: Option<Payloads>,
|
|
166
|
+
) -> Result<RespondActivityTaskCanceledResponse> {
|
|
167
|
+
WorkflowClientTrait::cancel_activity_task(self.borrow(), task_token, details).await
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async fn fail_activity_task(
|
|
171
|
+
&self,
|
|
172
|
+
task_token: TaskToken,
|
|
173
|
+
failure: Option<Failure>,
|
|
174
|
+
) -> Result<RespondActivityTaskFailedResponse> {
|
|
175
|
+
WorkflowClientTrait::fail_activity_task(self.borrow(), task_token, failure).await
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async fn fail_workflow_task(
|
|
179
|
+
&self,
|
|
180
|
+
task_token: TaskToken,
|
|
181
|
+
cause: WorkflowTaskFailedCause,
|
|
182
|
+
failure: Option<Failure>,
|
|
183
|
+
) -> Result<RespondWorkflowTaskFailedResponse> {
|
|
184
|
+
WorkflowClientTrait::fail_workflow_task(self.borrow(), task_token, cause, failure).await
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async fn get_workflow_execution_history(
|
|
188
|
+
&self,
|
|
189
|
+
workflow_id: String,
|
|
190
|
+
run_id: Option<String>,
|
|
191
|
+
page_token: Vec<u8>,
|
|
192
|
+
) -> Result<GetWorkflowExecutionHistoryResponse> {
|
|
193
|
+
WorkflowClientTrait::get_workflow_execution_history(
|
|
194
|
+
self.borrow(),
|
|
195
|
+
workflow_id,
|
|
196
|
+
run_id,
|
|
197
|
+
page_token,
|
|
198
|
+
)
|
|
199
|
+
.await
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async fn respond_legacy_query(
|
|
203
|
+
&self,
|
|
204
|
+
task_token: TaskToken,
|
|
205
|
+
query_result: QueryResult,
|
|
206
|
+
) -> Result<RespondQueryTaskCompletedResponse> {
|
|
207
|
+
WorkflowClientTrait::respond_legacy_query(self.borrow(), task_token, query_result).await
|
|
208
|
+
}
|
|
209
|
+
}
|