@temporalio/core-bridge 1.1.0 → 1.3.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 +786 -54
- package/Cargo.toml +2 -2
- package/common.js +7 -3
- package/index.d.ts +110 -3
- package/index.js +2 -6
- 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/scripts/build.js +4 -3
- package/sdk-core/.buildkite/docker/Dockerfile +2 -1
- package/sdk-core/ARCHITECTURE.md +2 -2
- package/sdk-core/README.md +12 -0
- package/sdk-core/bridge-ffi/Cargo.toml +2 -2
- package/sdk-core/client/Cargo.toml +6 -4
- package/sdk-core/client/src/lib.rs +338 -215
- package/sdk-core/client/src/raw.rs +352 -106
- package/sdk-core/client/src/retry.rs +159 -133
- package/sdk-core/client/src/workflow_handle/mod.rs +1 -1
- package/sdk-core/core/Cargo.toml +18 -9
- package/sdk-core/core/src/core_tests/activity_tasks.rs +63 -23
- package/sdk-core/core/src/core_tests/child_workflows.rs +125 -3
- package/sdk-core/core/src/core_tests/local_activities.rs +6 -6
- package/sdk-core/core/src/core_tests/workers.rs +3 -2
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +70 -2
- package/sdk-core/core/src/ephemeral_server/mod.rs +499 -0
- package/sdk-core/core/src/lib.rs +60 -26
- package/sdk-core/core/src/pollers/poll_buffer.rs +4 -4
- package/sdk-core/core/src/replay/mod.rs +3 -3
- package/sdk-core/core/src/retry_logic.rs +10 -9
- package/sdk-core/core/src/telemetry/mod.rs +10 -7
- package/sdk-core/core/src/test_help/mod.rs +18 -8
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +10 -10
- package/sdk-core/core/src/worker/activities/local_activities.rs +13 -13
- package/sdk-core/core/src/worker/activities.rs +6 -12
- package/sdk-core/core/src/worker/client.rs +193 -64
- package/sdk-core/core/src/worker/mod.rs +14 -19
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +3 -0
- package/sdk-core/core/src/worker/workflow/history_update.rs +5 -5
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +133 -85
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +3 -2
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +160 -105
- package/sdk-core/core/src/worker/workflow/managed_run.rs +2 -1
- package/sdk-core/core/src/worker/workflow/mod.rs +59 -58
- package/sdk-core/core/src/worker/workflow/run_cache.rs +5 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +7 -5
- package/sdk-core/core-api/Cargo.toml +2 -2
- package/sdk-core/core-api/src/errors.rs +3 -11
- package/sdk-core/core-api/src/worker.rs +7 -0
- package/sdk-core/protos/api_upstream/.buildkite/Dockerfile +1 -1
- package/sdk-core/protos/api_upstream/.github/CODEOWNERS +1 -1
- package/sdk-core/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +2 -6
- package/sdk-core/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +29 -0
- package/sdk-core/protos/api_upstream/Makefile +2 -2
- package/sdk-core/protos/api_upstream/buf.yaml +1 -0
- package/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +86 -0
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +26 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +46 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +7 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +14 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +51 -0
- package/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +18 -0
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +57 -1
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +1 -3
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +4 -2
- package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +11 -0
- package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +23 -0
- package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +46 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +1 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +172 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -0
- package/sdk-core/protos/grpc/health/v1/health.proto +63 -0
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +18 -15
- package/sdk-core/protos/testsrv_upstream/Makefile +80 -0
- package/sdk-core/protos/testsrv_upstream/api-linter.yaml +38 -0
- package/sdk-core/protos/testsrv_upstream/buf.yaml +13 -0
- package/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +141 -0
- package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +63 -0
- package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +90 -0
- package/sdk-core/sdk/Cargo.toml +2 -2
- package/sdk-core/sdk/src/lib.rs +2 -2
- package/sdk-core/sdk/src/workflow_context/options.rs +36 -8
- package/sdk-core/sdk/src/workflow_context.rs +30 -6
- package/sdk-core/sdk/src/workflow_future.rs +4 -4
- package/sdk-core/sdk-core-protos/Cargo.toml +5 -5
- package/sdk-core/sdk-core-protos/build.rs +9 -1
- package/sdk-core/sdk-core-protos/src/history_builder.rs +6 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +93 -32
- package/sdk-core/test-utils/Cargo.toml +3 -3
- package/sdk-core/test-utils/src/canned_histories.rs +58 -0
- package/sdk-core/test-utils/src/lib.rs +14 -10
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +141 -0
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +55 -5
- package/sdk-core/tests/integ_tests/polling_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/visibility_tests.rs +93 -0
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +93 -10
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +14 -14
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +12 -12
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +12 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +3 -3
- package/sdk-core/tests/integ_tests/workflow_tests.rs +19 -4
- package/sdk-core/tests/load_tests.rs +2 -1
- package/sdk-core/tests/main.rs +10 -0
- package/src/conversions.rs +138 -91
- package/src/helpers.rs +190 -0
- package/src/lib.rs +10 -912
- package/src/runtime.rs +436 -0
- package/src/testing.rs +67 -0
- package/src/worker.rs +465 -0
|
@@ -2,66 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
pub(crate) mod mocks;
|
|
4
4
|
|
|
5
|
-
use
|
|
6
|
-
borrow::Borrow,
|
|
7
|
-
ops::{Deref, DerefMut},
|
|
8
|
-
};
|
|
9
|
-
use temporal_client::{WorkflowClientTrait, WorkflowTaskCompletion, RETRYABLE_ERROR_CODES};
|
|
5
|
+
use temporal_client::{Client, RetryClient, WorkflowService, WorkflowTaskCompletion};
|
|
10
6
|
use temporal_sdk_core_protos::{
|
|
11
7
|
coresdk::workflow_commands::QueryResult,
|
|
12
8
|
temporal::api::{
|
|
13
|
-
common::v1::Payloads,
|
|
9
|
+
common::v1::{Payloads, WorkflowExecution},
|
|
10
|
+
enums::v1::{TaskQueueKind, WorkflowTaskFailedCause},
|
|
11
|
+
failure::v1::Failure,
|
|
12
|
+
query::v1::WorkflowQueryResult,
|
|
13
|
+
taskqueue::v1::{TaskQueue, TaskQueueMetadata},
|
|
14
14
|
workflowservice::v1::*,
|
|
15
15
|
},
|
|
16
16
|
TaskToken,
|
|
17
17
|
};
|
|
18
|
-
use tonic::Code;
|
|
19
18
|
|
|
20
19
|
type Result<T, E = tonic::Status> = std::result::Result<T, E>;
|
|
21
20
|
|
|
22
|
-
/// Returns true if the network error should not be reported to lang. This can happen if we've
|
|
23
|
-
/// exceeded the max number of retries, and we prefer to just warn rather than blowing up lang.
|
|
24
|
-
pub(crate) fn should_swallow_net_error(err: &tonic::Status) -> bool {
|
|
25
|
-
RETRYABLE_ERROR_CODES.contains(&err.code())
|
|
26
|
-
|| matches!(err.code(), Code::Cancelled | Code::DeadlineExceeded)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
21
|
/// Contains everything a worker needs to interact with the server
|
|
30
22
|
pub(crate) struct WorkerClientBag {
|
|
31
|
-
client:
|
|
23
|
+
client: RetryClient<Client>,
|
|
32
24
|
namespace: String,
|
|
25
|
+
identity: String,
|
|
26
|
+
worker_build_id: String,
|
|
27
|
+
use_versioning: bool,
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
impl WorkerClientBag {
|
|
36
|
-
pub fn new(
|
|
37
|
-
|
|
31
|
+
pub fn new(
|
|
32
|
+
client: RetryClient<Client>,
|
|
33
|
+
namespace: String,
|
|
34
|
+
identity: String,
|
|
35
|
+
worker_build_id: String,
|
|
36
|
+
use_versioning: bool,
|
|
37
|
+
) -> Self {
|
|
38
|
+
Self {
|
|
39
|
+
client,
|
|
40
|
+
namespace,
|
|
41
|
+
identity,
|
|
42
|
+
worker_build_id,
|
|
43
|
+
use_versioning,
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
type Target = dyn WorkerClient;
|
|
46
|
-
|
|
47
|
-
fn deref(&self) -> &Self::Target {
|
|
48
|
-
&*self.client
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
impl DerefMut for WorkerClientBag {
|
|
52
|
-
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
53
|
-
&mut *self.client
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
#[cfg(test)]
|
|
57
|
-
impl<T> From<T> for WorkerClientBag
|
|
58
|
-
where
|
|
59
|
-
T: WorkerClient + 'static,
|
|
60
|
-
{
|
|
61
|
-
fn from(c: T) -> Self {
|
|
62
|
-
use temporal_sdk_core_test_utils::NAMESPACE;
|
|
63
|
-
|
|
64
|
-
WorkerClientBag::new(Box::new(c), NAMESPACE.to_string())
|
|
46
|
+
fn versioning_build_id(&self) -> String {
|
|
47
|
+
if self.use_versioning {
|
|
48
|
+
self.worker_build_id.clone()
|
|
49
|
+
} else {
|
|
50
|
+
"".to_string()
|
|
51
|
+
}
|
|
65
52
|
}
|
|
66
53
|
}
|
|
67
54
|
|
|
@@ -124,17 +111,37 @@ pub(crate) trait WorkerClient: Sync + Send {
|
|
|
124
111
|
}
|
|
125
112
|
|
|
126
113
|
#[async_trait::async_trait]
|
|
127
|
-
impl
|
|
128
|
-
where
|
|
129
|
-
// TODO: This should be workflow service... no reason to marry worker trait to sdk client trait
|
|
130
|
-
T: Borrow<dyn WorkflowClientTrait + 'a + Send + Sync> + Send + Sync,
|
|
131
|
-
{
|
|
114
|
+
impl WorkerClient for WorkerClientBag {
|
|
132
115
|
async fn poll_workflow_task(
|
|
133
116
|
&self,
|
|
134
117
|
task_queue: String,
|
|
135
118
|
is_sticky: bool,
|
|
136
119
|
) -> Result<PollWorkflowTaskQueueResponse> {
|
|
137
|
-
|
|
120
|
+
let request = PollWorkflowTaskQueueRequest {
|
|
121
|
+
namespace: self.namespace.clone(),
|
|
122
|
+
task_queue: Some(TaskQueue {
|
|
123
|
+
name: task_queue,
|
|
124
|
+
kind: if is_sticky {
|
|
125
|
+
TaskQueueKind::Sticky
|
|
126
|
+
} else {
|
|
127
|
+
TaskQueueKind::Normal
|
|
128
|
+
} as i32,
|
|
129
|
+
}),
|
|
130
|
+
identity: self.identity.clone(),
|
|
131
|
+
binary_checksum: if self.use_versioning {
|
|
132
|
+
"".to_string()
|
|
133
|
+
} else {
|
|
134
|
+
self.worker_build_id.clone()
|
|
135
|
+
},
|
|
136
|
+
worker_versioning_build_id: self.versioning_build_id(),
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
Ok(self
|
|
140
|
+
.client
|
|
141
|
+
.clone()
|
|
142
|
+
.poll_workflow_task_queue(request)
|
|
143
|
+
.await?
|
|
144
|
+
.into_inner())
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
async fn poll_activity_task(
|
|
@@ -142,14 +149,62 @@ where
|
|
|
142
149
|
task_queue: String,
|
|
143
150
|
max_tasks_per_sec: Option<f64>,
|
|
144
151
|
) -> Result<PollActivityTaskQueueResponse> {
|
|
145
|
-
|
|
152
|
+
let request = PollActivityTaskQueueRequest {
|
|
153
|
+
namespace: self.namespace.clone(),
|
|
154
|
+
task_queue: Some(TaskQueue {
|
|
155
|
+
name: task_queue,
|
|
156
|
+
kind: TaskQueueKind::Normal as i32,
|
|
157
|
+
}),
|
|
158
|
+
identity: self.identity.clone(),
|
|
159
|
+
task_queue_metadata: max_tasks_per_sec.map(|tps| TaskQueueMetadata {
|
|
160
|
+
max_tasks_per_second: Some(tps),
|
|
161
|
+
}),
|
|
162
|
+
worker_versioning_build_id: self.versioning_build_id(),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
Ok(self
|
|
166
|
+
.client
|
|
167
|
+
.clone()
|
|
168
|
+
.poll_activity_task_queue(request)
|
|
169
|
+
.await?
|
|
170
|
+
.into_inner())
|
|
146
171
|
}
|
|
147
172
|
|
|
148
173
|
async fn complete_workflow_task(
|
|
149
174
|
&self,
|
|
150
175
|
request: WorkflowTaskCompletion,
|
|
151
176
|
) -> Result<RespondWorkflowTaskCompletedResponse> {
|
|
152
|
-
|
|
177
|
+
let request = RespondWorkflowTaskCompletedRequest {
|
|
178
|
+
task_token: request.task_token.into(),
|
|
179
|
+
commands: request.commands,
|
|
180
|
+
identity: self.identity.clone(),
|
|
181
|
+
sticky_attributes: request.sticky_attributes,
|
|
182
|
+
return_new_workflow_task: request.return_new_workflow_task,
|
|
183
|
+
force_create_new_workflow_task: request.force_create_new_workflow_task,
|
|
184
|
+
binary_checksum: self.worker_build_id.clone(),
|
|
185
|
+
query_results: request
|
|
186
|
+
.query_responses
|
|
187
|
+
.into_iter()
|
|
188
|
+
.map(|qr| {
|
|
189
|
+
let (id, completed_type, query_result, error_message) = qr.into_components();
|
|
190
|
+
(
|
|
191
|
+
id,
|
|
192
|
+
WorkflowQueryResult {
|
|
193
|
+
result_type: completed_type as i32,
|
|
194
|
+
answer: query_result,
|
|
195
|
+
error_message,
|
|
196
|
+
},
|
|
197
|
+
)
|
|
198
|
+
})
|
|
199
|
+
.collect(),
|
|
200
|
+
namespace: self.namespace.clone(),
|
|
201
|
+
};
|
|
202
|
+
Ok(self
|
|
203
|
+
.client
|
|
204
|
+
.clone()
|
|
205
|
+
.respond_workflow_task_completed(request)
|
|
206
|
+
.await?
|
|
207
|
+
.into_inner())
|
|
153
208
|
}
|
|
154
209
|
|
|
155
210
|
async fn complete_activity_task(
|
|
@@ -157,7 +212,17 @@ where
|
|
|
157
212
|
task_token: TaskToken,
|
|
158
213
|
result: Option<Payloads>,
|
|
159
214
|
) -> Result<RespondActivityTaskCompletedResponse> {
|
|
160
|
-
|
|
215
|
+
Ok(self
|
|
216
|
+
.client
|
|
217
|
+
.clone()
|
|
218
|
+
.respond_activity_task_completed(RespondActivityTaskCompletedRequest {
|
|
219
|
+
task_token: task_token.0,
|
|
220
|
+
result,
|
|
221
|
+
identity: self.identity.clone(),
|
|
222
|
+
namespace: self.namespace.clone(),
|
|
223
|
+
})
|
|
224
|
+
.await?
|
|
225
|
+
.into_inner())
|
|
161
226
|
}
|
|
162
227
|
|
|
163
228
|
async fn record_activity_heartbeat(
|
|
@@ -165,7 +230,17 @@ where
|
|
|
165
230
|
task_token: TaskToken,
|
|
166
231
|
details: Option<Payloads>,
|
|
167
232
|
) -> Result<RecordActivityTaskHeartbeatResponse> {
|
|
168
|
-
|
|
233
|
+
Ok(self
|
|
234
|
+
.client
|
|
235
|
+
.clone()
|
|
236
|
+
.record_activity_task_heartbeat(RecordActivityTaskHeartbeatRequest {
|
|
237
|
+
task_token: task_token.0,
|
|
238
|
+
details,
|
|
239
|
+
identity: self.identity.clone(),
|
|
240
|
+
namespace: self.namespace.clone(),
|
|
241
|
+
})
|
|
242
|
+
.await?
|
|
243
|
+
.into_inner())
|
|
169
244
|
}
|
|
170
245
|
|
|
171
246
|
async fn cancel_activity_task(
|
|
@@ -173,7 +248,17 @@ where
|
|
|
173
248
|
task_token: TaskToken,
|
|
174
249
|
details: Option<Payloads>,
|
|
175
250
|
) -> Result<RespondActivityTaskCanceledResponse> {
|
|
176
|
-
|
|
251
|
+
Ok(self
|
|
252
|
+
.client
|
|
253
|
+
.clone()
|
|
254
|
+
.respond_activity_task_canceled(RespondActivityTaskCanceledRequest {
|
|
255
|
+
task_token: task_token.0,
|
|
256
|
+
details,
|
|
257
|
+
identity: self.identity.clone(),
|
|
258
|
+
namespace: self.namespace.clone(),
|
|
259
|
+
})
|
|
260
|
+
.await?
|
|
261
|
+
.into_inner())
|
|
177
262
|
}
|
|
178
263
|
|
|
179
264
|
async fn fail_activity_task(
|
|
@@ -181,7 +266,19 @@ where
|
|
|
181
266
|
task_token: TaskToken,
|
|
182
267
|
failure: Option<Failure>,
|
|
183
268
|
) -> Result<RespondActivityTaskFailedResponse> {
|
|
184
|
-
|
|
269
|
+
Ok(self
|
|
270
|
+
.client
|
|
271
|
+
.clone()
|
|
272
|
+
.respond_activity_task_failed(RespondActivityTaskFailedRequest {
|
|
273
|
+
task_token: task_token.0,
|
|
274
|
+
failure,
|
|
275
|
+
identity: self.identity.clone(),
|
|
276
|
+
namespace: self.namespace.clone(),
|
|
277
|
+
// TODO: Implement - https://github.com/temporalio/sdk-core/issues/293
|
|
278
|
+
last_heartbeat_details: None,
|
|
279
|
+
})
|
|
280
|
+
.await?
|
|
281
|
+
.into_inner())
|
|
185
282
|
}
|
|
186
283
|
|
|
187
284
|
async fn fail_workflow_task(
|
|
@@ -190,7 +287,20 @@ where
|
|
|
190
287
|
cause: WorkflowTaskFailedCause,
|
|
191
288
|
failure: Option<Failure>,
|
|
192
289
|
) -> Result<RespondWorkflowTaskFailedResponse> {
|
|
193
|
-
|
|
290
|
+
let request = RespondWorkflowTaskFailedRequest {
|
|
291
|
+
task_token: task_token.0,
|
|
292
|
+
cause: cause as i32,
|
|
293
|
+
failure,
|
|
294
|
+
identity: self.identity.clone(),
|
|
295
|
+
binary_checksum: self.worker_build_id.clone(),
|
|
296
|
+
namespace: self.namespace.clone(),
|
|
297
|
+
};
|
|
298
|
+
Ok(self
|
|
299
|
+
.client
|
|
300
|
+
.clone()
|
|
301
|
+
.respond_workflow_task_failed(request)
|
|
302
|
+
.await?
|
|
303
|
+
.into_inner())
|
|
194
304
|
}
|
|
195
305
|
|
|
196
306
|
async fn get_workflow_execution_history(
|
|
@@ -199,13 +309,20 @@ where
|
|
|
199
309
|
run_id: Option<String>,
|
|
200
310
|
page_token: Vec<u8>,
|
|
201
311
|
) -> Result<GetWorkflowExecutionHistoryResponse> {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
312
|
+
Ok(self
|
|
313
|
+
.client
|
|
314
|
+
.clone()
|
|
315
|
+
.get_workflow_execution_history(GetWorkflowExecutionHistoryRequest {
|
|
316
|
+
namespace: self.namespace.clone(),
|
|
317
|
+
execution: Some(WorkflowExecution {
|
|
318
|
+
workflow_id,
|
|
319
|
+
run_id: run_id.unwrap_or_default(),
|
|
320
|
+
}),
|
|
321
|
+
next_page_token: page_token,
|
|
322
|
+
..Default::default()
|
|
323
|
+
})
|
|
324
|
+
.await?
|
|
325
|
+
.into_inner())
|
|
209
326
|
}
|
|
210
327
|
|
|
211
328
|
async fn respond_legacy_query(
|
|
@@ -213,6 +330,18 @@ where
|
|
|
213
330
|
task_token: TaskToken,
|
|
214
331
|
query_result: QueryResult,
|
|
215
332
|
) -> Result<RespondQueryTaskCompletedResponse> {
|
|
216
|
-
|
|
333
|
+
let (_, completed_type, query_result, error_message) = query_result.into_components();
|
|
334
|
+
Ok(self
|
|
335
|
+
.client
|
|
336
|
+
.clone()
|
|
337
|
+
.respond_query_task_completed(RespondQueryTaskCompletedRequest {
|
|
338
|
+
task_token: task_token.into(),
|
|
339
|
+
completed_type: completed_type as i32,
|
|
340
|
+
query_result,
|
|
341
|
+
error_message,
|
|
342
|
+
namespace: self.namespace.clone(),
|
|
343
|
+
})
|
|
344
|
+
.await?
|
|
345
|
+
.into_inner())
|
|
217
346
|
}
|
|
218
347
|
}
|
|
@@ -25,8 +25,8 @@ use crate::{
|
|
|
25
25
|
},
|
|
26
26
|
worker::{
|
|
27
27
|
activities::{DispatchOrTimeoutLA, LACompleteAction, LocalActivityManager},
|
|
28
|
-
client::
|
|
29
|
-
workflow::{LocalResolution, Workflows},
|
|
28
|
+
client::WorkerClient,
|
|
29
|
+
workflow::{LocalResolution, WorkflowBasics, Workflows},
|
|
30
30
|
},
|
|
31
31
|
ActivityHeartbeat, CompleteActivityError, PollActivityError, PollWfError, WorkerTrait,
|
|
32
32
|
};
|
|
@@ -50,14 +50,10 @@ use temporal_sdk_core_protos::{
|
|
|
50
50
|
};
|
|
51
51
|
use tokio_util::sync::CancellationToken;
|
|
52
52
|
|
|
53
|
-
#[cfg(test)]
|
|
54
|
-
use crate::worker::client::WorkerClient;
|
|
55
|
-
use crate::worker::workflow::WorkflowBasics;
|
|
56
|
-
|
|
57
53
|
/// A worker polls on a certain task queue
|
|
58
54
|
pub struct Worker {
|
|
59
55
|
config: WorkerConfig,
|
|
60
|
-
wf_client: Arc<
|
|
56
|
+
wf_client: Arc<dyn WorkerClient>,
|
|
61
57
|
|
|
62
58
|
/// Manages all workflows and WFT processing
|
|
63
59
|
workflows: Workflows,
|
|
@@ -156,7 +152,7 @@ impl Worker {
|
|
|
156
152
|
pub(crate) fn new(
|
|
157
153
|
config: WorkerConfig,
|
|
158
154
|
sticky_queue_name: Option<String>,
|
|
159
|
-
client: Arc<
|
|
155
|
+
client: Arc<dyn WorkerClient>,
|
|
160
156
|
metrics: MetricsContext,
|
|
161
157
|
) -> Self {
|
|
162
158
|
info!(task_queue = %config.task_queue, "Initializing worker");
|
|
@@ -228,13 +224,13 @@ impl Worker {
|
|
|
228
224
|
|
|
229
225
|
#[cfg(test)]
|
|
230
226
|
pub(crate) fn new_test(config: WorkerConfig, client: impl WorkerClient + 'static) -> Self {
|
|
231
|
-
Self::new(config, None, Arc::new(client
|
|
227
|
+
Self::new(config, None, Arc::new(client), Default::default())
|
|
232
228
|
}
|
|
233
229
|
|
|
234
230
|
pub(crate) fn new_with_pollers(
|
|
235
231
|
config: WorkerConfig,
|
|
236
232
|
sticky_queue_name: Option<String>,
|
|
237
|
-
client: Arc<
|
|
233
|
+
client: Arc<dyn WorkerClient>,
|
|
238
234
|
wft_stream: impl Stream<Item = Result<ValidPollWFTQResponse, tonic::Status>> + Send + 'static,
|
|
239
235
|
act_poller: Option<BoxedActPoller>,
|
|
240
236
|
metrics: MetricsContext,
|
|
@@ -266,6 +262,8 @@ impl Worker {
|
|
|
266
262
|
max_outstanding_wfts: config.max_outstanding_workflow_tasks,
|
|
267
263
|
shutdown_token: shutdown_token.child_token(),
|
|
268
264
|
metrics,
|
|
265
|
+
namespace: config.namespace.clone(),
|
|
266
|
+
task_queue: config.task_queue.clone(),
|
|
269
267
|
},
|
|
270
268
|
sticky_queue_name.map(|sq| StickyExecutionAttributes {
|
|
271
269
|
worker_task_queue: Some(TaskQueue {
|
|
@@ -273,7 +271,10 @@ impl Worker {
|
|
|
273
271
|
kind: TaskQueueKind::Sticky as i32,
|
|
274
272
|
}),
|
|
275
273
|
schedule_to_start_timeout: Some(
|
|
276
|
-
config
|
|
274
|
+
config
|
|
275
|
+
.sticky_queue_schedule_to_start_timeout
|
|
276
|
+
.try_into()
|
|
277
|
+
.expect("timeout fits into proto"),
|
|
277
278
|
),
|
|
278
279
|
}),
|
|
279
280
|
client,
|
|
@@ -422,20 +423,14 @@ impl Worker {
|
|
|
422
423
|
}
|
|
423
424
|
|
|
424
425
|
if let Some(atm) = &self.at_task_mgr {
|
|
425
|
-
|
|
426
|
-
Err(CompleteActivityError::TonicError(e)) if should_swallow_net_error(&e) => {
|
|
427
|
-
warn!(error=?e, "Network error while completing activity");
|
|
428
|
-
Ok(())
|
|
429
|
-
}
|
|
430
|
-
o => o,
|
|
431
|
-
}
|
|
426
|
+
atm.complete(task_token, status, &*self.wf_client).await;
|
|
432
427
|
} else {
|
|
433
428
|
error!(
|
|
434
429
|
"Tried to complete activity {} on a worker that does not have an activity manager",
|
|
435
430
|
task_token
|
|
436
431
|
);
|
|
437
|
-
Ok(())
|
|
438
432
|
}
|
|
433
|
+
Ok(())
|
|
439
434
|
}
|
|
440
435
|
|
|
441
436
|
#[instrument(level = "debug", skip(self), fields(run_id))]
|
|
@@ -45,6 +45,9 @@ impl DrivenWorkflow {
|
|
|
45
45
|
.workflow_execution_timeout
|
|
46
46
|
.clone()
|
|
47
47
|
.try_into_or_none(),
|
|
48
|
+
memo: attribs.memo.clone(),
|
|
49
|
+
search_attrs: attribs.search_attributes.clone(),
|
|
50
|
+
retry_policy: attribs.retry_policy.clone(),
|
|
48
51
|
};
|
|
49
52
|
self.send_job(start_workflow_from_attribs(attribs, workflow_id, randomness_seed).into());
|
|
50
53
|
self.started_attrs = Some(started_info);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
replay::{HistoryInfo, TestHistoryBuilder},
|
|
3
|
-
worker::client::
|
|
3
|
+
worker::client::WorkerClient,
|
|
4
4
|
};
|
|
5
5
|
use futures::{future::BoxFuture, stream, stream::BoxStream, FutureExt, Stream, StreamExt};
|
|
6
6
|
use std::{
|
|
@@ -42,7 +42,7 @@ impl Debug for HistoryUpdate {
|
|
|
42
42
|
|
|
43
43
|
pub struct HistoryPaginator {
|
|
44
44
|
// Potentially this could actually be a ref w/ lifetime here
|
|
45
|
-
client: Arc<
|
|
45
|
+
client: Arc<dyn WorkerClient>,
|
|
46
46
|
event_queue: VecDeque<HistoryEvent>,
|
|
47
47
|
wf_id: String,
|
|
48
48
|
run_id: String,
|
|
@@ -82,7 +82,7 @@ impl HistoryPaginator {
|
|
|
82
82
|
wf_id: String,
|
|
83
83
|
run_id: String,
|
|
84
84
|
next_page_token: impl Into<NextPageToken>,
|
|
85
|
-
client: Arc<
|
|
85
|
+
client: Arc<dyn WorkerClient>,
|
|
86
86
|
) -> Self {
|
|
87
87
|
let next_page_token = next_page_token.into();
|
|
88
88
|
let (event_queue, final_events) =
|
|
@@ -397,7 +397,7 @@ pub mod tests {
|
|
|
397
397
|
"wfid".to_string(),
|
|
398
398
|
"runid".to_string(),
|
|
399
399
|
vec![2], // Start at page "2"
|
|
400
|
-
Arc::new(mock_client
|
|
400
|
+
Arc::new(mock_client),
|
|
401
401
|
),
|
|
402
402
|
prev_started,
|
|
403
403
|
);
|
|
@@ -442,7 +442,7 @@ pub mod tests {
|
|
|
442
442
|
"runid".to_string(),
|
|
443
443
|
// A cache miss means we'll try to fetch from start
|
|
444
444
|
NextPageToken::FetchFromStart,
|
|
445
|
-
Arc::new(mock_client
|
|
445
|
+
Arc::new(mock_client),
|
|
446
446
|
),
|
|
447
447
|
1,
|
|
448
448
|
);
|