@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,14 +1,20 @@
|
|
|
1
1
|
use assert_matches::assert_matches;
|
|
2
2
|
use std::time::Duration;
|
|
3
|
+
use temporal_sdk::{ActivityOptions, WfContext, WorkflowResult};
|
|
3
4
|
use temporal_sdk_core_protos::{
|
|
4
5
|
coresdk::{
|
|
5
|
-
activity_result::{
|
|
6
|
+
activity_result::{
|
|
7
|
+
self, activity_resolution, activity_resolution as act_res, ActivityExecutionResult,
|
|
8
|
+
ActivityResolution,
|
|
9
|
+
},
|
|
6
10
|
activity_task::activity_task as act_task,
|
|
7
11
|
common::Payload,
|
|
8
|
-
workflow_activation::{
|
|
12
|
+
workflow_activation::{
|
|
13
|
+
workflow_activation_job, FireTimer, ResolveActivity, WorkflowActivationJob,
|
|
14
|
+
},
|
|
9
15
|
workflow_commands::{ActivityCancellationType, RequestCancelActivity, StartTimer},
|
|
10
|
-
workflow_completion::
|
|
11
|
-
ActivityHeartbeat, ActivityTaskCompletion, IntoCompletion,
|
|
16
|
+
workflow_completion::WorkflowActivationCompletion,
|
|
17
|
+
ActivityHeartbeat, ActivityTaskCompletion, AsJsonPayloadExt, IntoCompletion,
|
|
12
18
|
},
|
|
13
19
|
temporal::api::{
|
|
14
20
|
common::v1::{ActivityType, Payloads},
|
|
@@ -16,9 +22,40 @@ use temporal_sdk_core_protos::{
|
|
|
16
22
|
failure::v1::{failure::FailureInfo, ActivityFailureInfo, Failure},
|
|
17
23
|
},
|
|
18
24
|
};
|
|
19
|
-
use
|
|
25
|
+
use temporal_sdk_core_test_utils::{
|
|
26
|
+
init_core_and_create_wf, schedule_activity_cmd, CoreTestHelpers, CoreWfStarter,
|
|
27
|
+
};
|
|
20
28
|
use tokio::time::sleep;
|
|
21
29
|
|
|
30
|
+
pub async fn one_activity_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
31
|
+
ctx.activity(ActivityOptions {
|
|
32
|
+
activity_type: "echo_activity".to_string(),
|
|
33
|
+
start_to_close_timeout: Some(Duration::from_secs(5)),
|
|
34
|
+
input: "hi!".as_json_payload().expect("serializes fine"),
|
|
35
|
+
..Default::default()
|
|
36
|
+
})
|
|
37
|
+
.await;
|
|
38
|
+
Ok(().into())
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[tokio::test]
|
|
42
|
+
async fn one_activity() {
|
|
43
|
+
let wf_name = "one_activity";
|
|
44
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
|
45
|
+
let mut worker = starter.worker().await;
|
|
46
|
+
worker.register_wf(wf_name.to_owned(), one_activity_wf);
|
|
47
|
+
worker.register_activity(
|
|
48
|
+
"echo_activity",
|
|
49
|
+
|echo_me: String| async move { Ok(echo_me) },
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
worker
|
|
53
|
+
.submit_wf(wf_name.to_owned(), wf_name.to_owned(), vec![])
|
|
54
|
+
.await
|
|
55
|
+
.unwrap();
|
|
56
|
+
worker.run_until_done().await.unwrap();
|
|
57
|
+
}
|
|
58
|
+
|
|
22
59
|
#[tokio::test]
|
|
23
60
|
async fn activity_workflow() {
|
|
24
61
|
let (core, task_q) = init_core_and_create_wf("activity_workflow").await;
|
|
@@ -54,7 +91,7 @@ async fn activity_workflow() {
|
|
|
54
91
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
55
92
|
task_token: task.task_token,
|
|
56
93
|
task_queue: task_q.to_string(),
|
|
57
|
-
result: Some(
|
|
94
|
+
result: Some(ActivityExecutionResult::ok(response_payload.clone())),
|
|
58
95
|
})
|
|
59
96
|
.await
|
|
60
97
|
.unwrap();
|
|
@@ -63,11 +100,13 @@ async fn activity_workflow() {
|
|
|
63
100
|
assert_matches!(
|
|
64
101
|
task.jobs.as_slice(),
|
|
65
102
|
[
|
|
66
|
-
|
|
67
|
-
variant: Some(
|
|
68
|
-
ResolveActivity {seq, result: Some(
|
|
69
|
-
|
|
70
|
-
|
|
103
|
+
WorkflowActivationJob {
|
|
104
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
105
|
+
ResolveActivity {seq, result: Some(ActivityResolution{
|
|
106
|
+
status: Some(
|
|
107
|
+
act_res::Status::Completed(activity_result::Success{result: Some(r)})),
|
|
108
|
+
..
|
|
109
|
+
})}
|
|
71
110
|
)),
|
|
72
111
|
},
|
|
73
112
|
] => {
|
|
@@ -110,13 +149,7 @@ async fn activity_non_retryable_failure() {
|
|
|
110
149
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
111
150
|
task_token: task.task_token,
|
|
112
151
|
task_queue: task_q.to_string(),
|
|
113
|
-
result: Some(
|
|
114
|
-
status: Some(activity_result::activity_result::Status::Failed(
|
|
115
|
-
activity_result::Failure {
|
|
116
|
-
failure: Some(failure.clone()),
|
|
117
|
-
},
|
|
118
|
-
)),
|
|
119
|
-
}),
|
|
152
|
+
result: Some(ActivityExecutionResult::fail(failure.clone())),
|
|
120
153
|
})
|
|
121
154
|
.await
|
|
122
155
|
.unwrap();
|
|
@@ -125,9 +158,9 @@ async fn activity_non_retryable_failure() {
|
|
|
125
158
|
assert_matches!(
|
|
126
159
|
task.jobs.as_slice(),
|
|
127
160
|
[
|
|
128
|
-
|
|
129
|
-
variant: Some(
|
|
130
|
-
ResolveActivity {seq, result: Some(
|
|
161
|
+
WorkflowActivationJob {
|
|
162
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
163
|
+
ResolveActivity {seq, result: Some(ActivityResolution{
|
|
131
164
|
status: Some(act_res::Status::Failed(activity_result::Failure{
|
|
132
165
|
failure: Some(f),
|
|
133
166
|
}))})}
|
|
@@ -187,13 +220,7 @@ async fn activity_retry() {
|
|
|
187
220
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
188
221
|
task_token: task.task_token,
|
|
189
222
|
task_queue: task_q.to_string(),
|
|
190
|
-
result: Some(
|
|
191
|
-
status: Some(activity_result::activity_result::Status::Failed(
|
|
192
|
-
activity_result::Failure {
|
|
193
|
-
failure: Some(failure),
|
|
194
|
-
},
|
|
195
|
-
)),
|
|
196
|
-
}),
|
|
223
|
+
result: Some(ActivityExecutionResult::fail(failure)),
|
|
197
224
|
})
|
|
198
225
|
.await
|
|
199
226
|
.unwrap();
|
|
@@ -213,7 +240,7 @@ async fn activity_retry() {
|
|
|
213
240
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
214
241
|
task_token: task.task_token,
|
|
215
242
|
task_queue: task_q.to_string(),
|
|
216
|
-
result: Some(
|
|
243
|
+
result: Some(ActivityExecutionResult::ok(response_payload.clone())),
|
|
217
244
|
})
|
|
218
245
|
.await
|
|
219
246
|
.unwrap();
|
|
@@ -222,9 +249,9 @@ async fn activity_retry() {
|
|
|
222
249
|
assert_matches!(
|
|
223
250
|
task.jobs.as_slice(),
|
|
224
251
|
[
|
|
225
|
-
|
|
226
|
-
variant: Some(
|
|
227
|
-
ResolveActivity {seq, result: Some(
|
|
252
|
+
WorkflowActivationJob {
|
|
253
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
254
|
+
ResolveActivity {seq, result: Some(ActivityResolution{
|
|
228
255
|
status: Some(act_res::Status::Completed(activity_result::Success{result: Some(r)}))})}
|
|
229
256
|
)),
|
|
230
257
|
},
|
|
@@ -276,8 +303,8 @@ async fn activity_cancellation_try_cancel() {
|
|
|
276
303
|
assert_matches!(
|
|
277
304
|
task.jobs.as_slice(),
|
|
278
305
|
[
|
|
279
|
-
|
|
280
|
-
variant: Some(
|
|
306
|
+
WorkflowActivationJob {
|
|
307
|
+
variant: Some(workflow_activation_job::Variant::FireTimer(
|
|
281
308
|
FireTimer { seq }
|
|
282
309
|
)),
|
|
283
310
|
},
|
|
@@ -285,7 +312,7 @@ async fn activity_cancellation_try_cancel() {
|
|
|
285
312
|
assert_eq!(*seq, 1);
|
|
286
313
|
}
|
|
287
314
|
);
|
|
288
|
-
core.complete_workflow_activation(
|
|
315
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
289
316
|
&task_q,
|
|
290
317
|
task.run_id,
|
|
291
318
|
vec![RequestCancelActivity { seq: 0 }.into()],
|
|
@@ -328,11 +355,11 @@ async fn activity_cancellation_plus_complete_doesnt_double_resolve() {
|
|
|
328
355
|
let task = core.poll_workflow_activation(&task_q).await.unwrap();
|
|
329
356
|
assert_matches!(
|
|
330
357
|
task.jobs.as_slice(),
|
|
331
|
-
[
|
|
332
|
-
variant: Some(
|
|
358
|
+
[WorkflowActivationJob {
|
|
359
|
+
variant: Some(workflow_activation_job::Variant::FireTimer(_)),
|
|
333
360
|
}]
|
|
334
361
|
);
|
|
335
|
-
core.complete_workflow_activation(
|
|
362
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
336
363
|
&task_q,
|
|
337
364
|
task.run_id,
|
|
338
365
|
vec![RequestCancelActivity { seq: 0 }.into()],
|
|
@@ -343,11 +370,11 @@ async fn activity_cancellation_plus_complete_doesnt_double_resolve() {
|
|
|
343
370
|
// Should get cancel task
|
|
344
371
|
assert_matches!(
|
|
345
372
|
task.jobs.as_slice(),
|
|
346
|
-
[
|
|
347
|
-
variant: Some(
|
|
373
|
+
[WorkflowActivationJob {
|
|
374
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
348
375
|
ResolveActivity {
|
|
349
|
-
result: Some(
|
|
350
|
-
status: Some(
|
|
376
|
+
result: Some(ActivityResolution {
|
|
377
|
+
status: Some(activity_resolution::Status::Cancelled(_))
|
|
351
378
|
}),
|
|
352
379
|
..
|
|
353
380
|
}
|
|
@@ -356,7 +383,7 @@ async fn activity_cancellation_plus_complete_doesnt_double_resolve() {
|
|
|
356
383
|
);
|
|
357
384
|
// We need to complete the wf task to send the activity cancel command to the server, so start
|
|
358
385
|
// another short timer
|
|
359
|
-
core.complete_workflow_activation(
|
|
386
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
360
387
|
&task_q,
|
|
361
388
|
task.run_id,
|
|
362
389
|
vec![StartTimer {
|
|
@@ -371,14 +398,7 @@ async fn activity_cancellation_plus_complete_doesnt_double_resolve() {
|
|
|
371
398
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
372
399
|
task_token: activity_task.task_token,
|
|
373
400
|
task_queue: task_q.to_string(),
|
|
374
|
-
result: Some(
|
|
375
|
-
status: Some(
|
|
376
|
-
activity_result::Success {
|
|
377
|
-
result: Some(vec![1].into()),
|
|
378
|
-
}
|
|
379
|
-
.into(),
|
|
380
|
-
),
|
|
381
|
-
}),
|
|
401
|
+
result: Some(ActivityExecutionResult::ok([1].into())),
|
|
382
402
|
})
|
|
383
403
|
.await
|
|
384
404
|
.unwrap();
|
|
@@ -388,8 +408,8 @@ async fn activity_cancellation_plus_complete_doesnt_double_resolve() {
|
|
|
388
408
|
let task = core.poll_workflow_activation(&task_q).await.unwrap();
|
|
389
409
|
assert_matches!(
|
|
390
410
|
task.jobs.as_slice(),
|
|
391
|
-
[
|
|
392
|
-
variant: Some(
|
|
411
|
+
[WorkflowActivationJob {
|
|
412
|
+
variant: Some(workflow_activation_job::Variant::FireTimer(_)),
|
|
393
413
|
}]
|
|
394
414
|
);
|
|
395
415
|
core.complete_execution(&task_q, &task.run_id).await;
|
|
@@ -427,11 +447,11 @@ async fn started_activity_timeout() {
|
|
|
427
447
|
assert_matches!(
|
|
428
448
|
task.jobs.as_slice(),
|
|
429
449
|
[
|
|
430
|
-
|
|
431
|
-
variant: Some(
|
|
450
|
+
WorkflowActivationJob {
|
|
451
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
432
452
|
ResolveActivity {
|
|
433
453
|
seq,
|
|
434
|
-
result: Some(
|
|
454
|
+
result: Some(ActivityResolution{
|
|
435
455
|
status: Some(
|
|
436
456
|
act_res::Status::Failed(
|
|
437
457
|
activity_result::Failure{failure: Some(_)}
|
|
@@ -490,8 +510,8 @@ async fn activity_cancellation_wait_cancellation_completed() {
|
|
|
490
510
|
assert_matches!(
|
|
491
511
|
task.jobs.as_slice(),
|
|
492
512
|
[
|
|
493
|
-
|
|
494
|
-
variant: Some(
|
|
513
|
+
WorkflowActivationJob {
|
|
514
|
+
variant: Some(workflow_activation_job::Variant::FireTimer(
|
|
495
515
|
FireTimer { seq }
|
|
496
516
|
)),
|
|
497
517
|
},
|
|
@@ -499,7 +519,7 @@ async fn activity_cancellation_wait_cancellation_completed() {
|
|
|
499
519
|
assert_eq!(*seq, 1);
|
|
500
520
|
}
|
|
501
521
|
);
|
|
502
|
-
core.complete_workflow_activation(
|
|
522
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
503
523
|
&task_q,
|
|
504
524
|
task.run_id,
|
|
505
525
|
vec![RequestCancelActivity { seq: 0 }.into()],
|
|
@@ -509,7 +529,7 @@ async fn activity_cancellation_wait_cancellation_completed() {
|
|
|
509
529
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
510
530
|
task_token: activity_task.task_token,
|
|
511
531
|
task_queue: task_q.to_string(),
|
|
512
|
-
result: Some(
|
|
532
|
+
result: Some(ActivityExecutionResult::cancel_from_details(None)),
|
|
513
533
|
})
|
|
514
534
|
.await
|
|
515
535
|
.unwrap();
|
|
@@ -557,8 +577,8 @@ async fn activity_cancellation_abandon() {
|
|
|
557
577
|
assert_matches!(
|
|
558
578
|
task.jobs.as_slice(),
|
|
559
579
|
[
|
|
560
|
-
|
|
561
|
-
variant: Some(
|
|
580
|
+
WorkflowActivationJob {
|
|
581
|
+
variant: Some(workflow_activation_job::Variant::FireTimer(
|
|
562
582
|
FireTimer { seq }
|
|
563
583
|
)),
|
|
564
584
|
},
|
|
@@ -566,7 +586,7 @@ async fn activity_cancellation_abandon() {
|
|
|
566
586
|
assert_eq!(*seq, 1);
|
|
567
587
|
}
|
|
568
588
|
);
|
|
569
|
-
core.complete_workflow_activation(
|
|
589
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
570
590
|
&task_q,
|
|
571
591
|
task.run_id,
|
|
572
592
|
vec![RequestCancelActivity { seq: 0 }.into()],
|
|
@@ -614,7 +634,7 @@ async fn async_activity_completion_workflow() {
|
|
|
614
634
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
615
635
|
task_token: task.task_token.clone(),
|
|
616
636
|
task_queue: task_q.to_string(),
|
|
617
|
-
result: Some(
|
|
637
|
+
result: Some(ActivityExecutionResult::will_complete_async()),
|
|
618
638
|
})
|
|
619
639
|
.await
|
|
620
640
|
.unwrap();
|
|
@@ -633,9 +653,9 @@ async fn async_activity_completion_workflow() {
|
|
|
633
653
|
assert_matches!(
|
|
634
654
|
task.jobs.as_slice(),
|
|
635
655
|
[
|
|
636
|
-
|
|
637
|
-
variant: Some(
|
|
638
|
-
ResolveActivity {seq, result: Some(
|
|
656
|
+
WorkflowActivationJob {
|
|
657
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
658
|
+
ResolveActivity {seq, result: Some(ActivityResolution {
|
|
639
659
|
status: Some(act_res::Status::Completed(activity_result::Success{result: Some(r)})),
|
|
640
660
|
..})}
|
|
641
661
|
)),
|
|
@@ -650,8 +670,8 @@ async fn async_activity_completion_workflow() {
|
|
|
650
670
|
|
|
651
671
|
#[tokio::test]
|
|
652
672
|
async fn activity_cancelled_after_heartbeat_times_out() {
|
|
653
|
-
let
|
|
654
|
-
|
|
673
|
+
let (core, task_q) =
|
|
674
|
+
init_core_and_create_wf("activity_cancelled_after_heartbeat_times_out").await;
|
|
655
675
|
let activity_id = "act-1";
|
|
656
676
|
let task = core.poll_workflow_activation(&task_q).await.unwrap();
|
|
657
677
|
// Complete workflow task and schedule activity
|
|
@@ -693,7 +713,7 @@ async fn activity_cancelled_after_heartbeat_times_out() {
|
|
|
693
713
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
694
714
|
task_token: task.task_token.clone(),
|
|
695
715
|
task_queue: task_q.to_string(),
|
|
696
|
-
result: Some(
|
|
716
|
+
result: Some(ActivityExecutionResult::cancel_from_details(None)),
|
|
697
717
|
})
|
|
698
718
|
.await
|
|
699
719
|
.unwrap();
|
|
@@ -703,7 +723,7 @@ async fn activity_cancelled_after_heartbeat_times_out() {
|
|
|
703
723
|
core.shutdown().await;
|
|
704
724
|
// Cleanup just in case
|
|
705
725
|
core.server_gateway()
|
|
706
|
-
.terminate_workflow_execution(
|
|
726
|
+
.terminate_workflow_execution(task_q, None)
|
|
707
727
|
.await
|
|
708
728
|
.unwrap();
|
|
709
729
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
use
|
|
1
|
+
use temporal_sdk::{WfContext, WorkflowResult};
|
|
2
2
|
use temporal_sdk_core_protos::coresdk::common::NamespacedWorkflowExecution;
|
|
3
|
-
use
|
|
3
|
+
use temporal_sdk_core_test_utils::CoreWfStarter;
|
|
4
4
|
|
|
5
5
|
const RECEIVER_WFID: &str = "sends-cancel-receiver";
|
|
6
6
|
|
|
7
|
-
async fn cancel_sender(
|
|
7
|
+
async fn cancel_sender(ctx: WfContext) -> WorkflowResult<()> {
|
|
8
8
|
let run_id = std::str::from_utf8(&ctx.get_args()[0].data)
|
|
9
9
|
.unwrap()
|
|
10
10
|
.to_owned();
|
|
@@ -49,5 +49,4 @@ async fn sends_cancel_to_other_wf() {
|
|
|
49
49
|
.await
|
|
50
50
|
.unwrap();
|
|
51
51
|
worker.run_until_done().await.unwrap();
|
|
52
|
-
starter.shutdown().await;
|
|
53
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use std::time::Duration;
|
|
2
|
-
use
|
|
2
|
+
use temporal_sdk::{WfContext, WfExitValue, WorkflowResult};
|
|
3
3
|
use temporal_sdk_core_protos::temporal::api::enums::v1::WorkflowExecutionStatus;
|
|
4
|
-
use
|
|
4
|
+
use temporal_sdk_core_test_utils::CoreWfStarter;
|
|
5
5
|
|
|
6
6
|
async fn cancelled_wf(mut ctx: WfContext) -> WorkflowResult<()> {
|
|
7
7
|
let cancelled = tokio::select! {
|
|
@@ -50,6 +50,4 @@ async fn cancel_during_timer() {
|
|
|
50
50
|
desc.workflow_execution_info.unwrap().status,
|
|
51
51
|
WorkflowExecutionStatus::Canceled as i32
|
|
52
52
|
);
|
|
53
|
-
|
|
54
|
-
starter.shutdown().await;
|
|
55
53
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use anyhow::anyhow;
|
|
2
|
-
use
|
|
2
|
+
use temporal_sdk::{ChildWorkflowOptions, WfContext, WorkflowResult};
|
|
3
3
|
use temporal_sdk_core_protos::coresdk::child_workflow::{child_workflow_result, Success};
|
|
4
|
-
use
|
|
4
|
+
use temporal_sdk_core_test_utils::CoreWfStarter;
|
|
5
5
|
|
|
6
6
|
static PARENT_WF_TYPE: &str = "parent_wf";
|
|
7
7
|
static CHILD_WF_TYPE: &str = "child_wf";
|
|
@@ -10,7 +10,7 @@ async fn child_wf(_ctx: WfContext) -> WorkflowResult<()> {
|
|
|
10
10
|
Ok(().into())
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async fn parent_wf(
|
|
13
|
+
async fn parent_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
14
14
|
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
15
15
|
workflow_id: "child-1".to_owned(),
|
|
16
16
|
workflow_type: CHILD_WF_TYPE.to_owned(),
|
|
@@ -18,7 +18,7 @@ async fn parent_wf(mut ctx: WfContext) -> WorkflowResult<()> {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
let started = child
|
|
21
|
-
.start(&
|
|
21
|
+
.start(&ctx)
|
|
22
22
|
.await
|
|
23
23
|
.into_started()
|
|
24
24
|
.expect("Child chould start OK");
|
|
@@ -42,6 +42,4 @@ async fn child_workflow_happy_path() {
|
|
|
42
42
|
.await
|
|
43
43
|
.unwrap();
|
|
44
44
|
worker.run_until_done().await.unwrap();
|
|
45
|
-
|
|
46
|
-
starter.shutdown().await;
|
|
47
45
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
use std::time::Duration;
|
|
2
|
-
use
|
|
2
|
+
use temporal_sdk::{WfContext, WfExitValue, WorkflowResult};
|
|
3
3
|
use temporal_sdk_core_protos::coresdk::workflow_commands::ContinueAsNewWorkflowExecution;
|
|
4
|
-
use
|
|
4
|
+
use temporal_sdk_core_test_utils::CoreWfStarter;
|
|
5
5
|
|
|
6
|
-
async fn continue_as_new_wf(
|
|
6
|
+
async fn continue_as_new_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
7
7
|
let run_ct = ctx.get_args()[0].data[0];
|
|
8
8
|
ctx.timer(Duration::from_millis(500)).await;
|
|
9
9
|
Ok(if run_ct < 5 {
|
|
10
|
-
WfExitValue::
|
|
10
|
+
WfExitValue::continue_as_new(ContinueAsNewWorkflowExecution {
|
|
11
11
|
arguments: vec![[run_ct + 1].into()],
|
|
12
12
|
..Default::default()
|
|
13
13
|
})
|
|
@@ -37,6 +37,4 @@ async fn continue_as_new_happy_path() {
|
|
|
37
37
|
.terminate_workflow_execution(wf_name.to_owned(), None)
|
|
38
38
|
.await
|
|
39
39
|
.unwrap();
|
|
40
|
-
|
|
41
|
-
starter.shutdown().await;
|
|
42
40
|
}
|
|
@@ -2,11 +2,11 @@ use std::{
|
|
|
2
2
|
sync::atomic::{AtomicUsize, Ordering},
|
|
3
3
|
time::Duration,
|
|
4
4
|
};
|
|
5
|
-
use
|
|
6
|
-
use
|
|
5
|
+
use temporal_sdk::{ActivityOptions, WfContext, WorkflowResult};
|
|
6
|
+
use temporal_sdk_core_test_utils::CoreWfStarter;
|
|
7
7
|
|
|
8
8
|
static RUN_CT: AtomicUsize = AtomicUsize::new(1);
|
|
9
|
-
pub async fn timer_wf_nondeterministic(
|
|
9
|
+
pub async fn timer_wf_nondeterministic(ctx: WfContext) -> WorkflowResult<()> {
|
|
10
10
|
let run_ct = RUN_CT.fetch_add(1, Ordering::Relaxed);
|
|
11
11
|
|
|
12
12
|
match run_ct {
|
|
@@ -43,7 +43,6 @@ async fn test_determinism_error_then_recovers() {
|
|
|
43
43
|
.await
|
|
44
44
|
.unwrap();
|
|
45
45
|
worker.run_until_done().await.unwrap();
|
|
46
|
-
starter.shutdown().await;
|
|
47
46
|
// 4 because we still add on the 3rd and final attempt
|
|
48
47
|
assert_eq!(RUN_CT.load(Ordering::Relaxed), 4);
|
|
49
48
|
}
|