@temporalio/core-bridge 0.17.2 → 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 +45 -52
- 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 +264 -286
- 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 +34 -73
- 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 +305 -195
- 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 +19 -21
- 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 +344 -160
- 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 +297 -81
- package/sdk-core/{test_utils → core-api}/Cargo.toml +10 -7
- package/sdk-core/{src → core-api/src}/errors.rs +42 -90
- 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 +594 -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 -158
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
use crate::{pollers, pollers::BoxedWFPoller};
|
|
2
|
+
use crossbeam::queue::SegQueue;
|
|
3
|
+
use temporal_sdk_core_protos::temporal::api::workflowservice::v1::PollWorkflowTaskQueueResponse;
|
|
4
|
+
use tokio::sync::Notify;
|
|
5
|
+
|
|
6
|
+
/// Workflow tasks typically come from polling, but may also come as a response to task completion.
|
|
7
|
+
/// This struct allows fetching WFTs to be centralized while prioritizing tasks from completes.
|
|
8
|
+
pub(crate) struct WFTSource {
|
|
9
|
+
from_completions: SegQueue<PollWorkflowTaskQueueResponse>,
|
|
10
|
+
poll_buffer: BoxedWFPoller,
|
|
11
|
+
task_taken_notifier: Notify,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
impl WFTSource {
|
|
15
|
+
pub fn new(poller: BoxedWFPoller) -> Self {
|
|
16
|
+
Self {
|
|
17
|
+
from_completions: SegQueue::new(),
|
|
18
|
+
poll_buffer: poller,
|
|
19
|
+
task_taken_notifier: Notify::new(),
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// Returns the next available WFT if one is already stored from a completion, otherwise
|
|
24
|
+
/// forwards to the poller.
|
|
25
|
+
pub async fn next_wft(&self) -> Option<pollers::Result<PollWorkflowTaskQueueResponse>> {
|
|
26
|
+
if let Some(wft) = self.from_completions.pop() {
|
|
27
|
+
self.task_taken_notifier.notify_one();
|
|
28
|
+
return Some(Ok(wft));
|
|
29
|
+
}
|
|
30
|
+
self.poll_buffer.poll().await
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Add a WFT received from the completion of another WFT
|
|
34
|
+
pub fn add_wft_from_completion(&self, wft: PollWorkflowTaskQueueResponse) {
|
|
35
|
+
self.from_completions.push(wft);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// Notifies the pollers to stop polling
|
|
39
|
+
pub fn stop_pollers(&self) {
|
|
40
|
+
self.poll_buffer.notify_shutdown();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Returns true if there are tasks from completion buffered which need to be handled
|
|
44
|
+
pub fn has_tasks_from_complete(&self) -> bool {
|
|
45
|
+
!self.from_completions.is_empty()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// Returns a future which resolves when all tasks from completions have been taken
|
|
49
|
+
pub async fn wait_for_tasks_from_complete_to_drain(&self) {
|
|
50
|
+
while !self.from_completions.is_empty() {
|
|
51
|
+
self.task_taken_notifier.notified().await;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// Wait for poll shutdown to complete
|
|
56
|
+
pub async fn shutdown(self) {
|
|
57
|
+
self.poll_buffer.shutdown_box().await;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[cfg(test)]
|
|
62
|
+
mod tests {
|
|
63
|
+
use super::*;
|
|
64
|
+
use crate::test_help::mock_poller;
|
|
65
|
+
|
|
66
|
+
#[tokio::test]
|
|
67
|
+
async fn drains_from_completes_on_shutdown() {
|
|
68
|
+
let mp = mock_poller();
|
|
69
|
+
let wftsrc = WFTSource::new(Box::new(mp));
|
|
70
|
+
let fake_wft = PollWorkflowTaskQueueResponse {
|
|
71
|
+
started_event_id: 1,
|
|
72
|
+
..Default::default()
|
|
73
|
+
};
|
|
74
|
+
wftsrc.add_wft_from_completion(fake_wft);
|
|
75
|
+
let fake_wft = PollWorkflowTaskQueueResponse {
|
|
76
|
+
started_event_id: 2,
|
|
77
|
+
..Default::default()
|
|
78
|
+
};
|
|
79
|
+
wftsrc.add_wft_from_completion(fake_wft);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
use crate::{
|
|
1
|
+
use crate::{
|
|
2
|
+
telemetry::VecDisplayer,
|
|
3
|
+
workflow::{WFCommand, WorkflowFetcher},
|
|
4
|
+
};
|
|
2
5
|
use std::sync::mpsc::{self, Receiver, Sender};
|
|
3
6
|
|
|
4
7
|
/// The [DrivenWorkflow] trait expects to be called to make progress, but the [CoreSDKService]
|
|
@@ -28,7 +31,7 @@ impl WorkflowFetcher for WorkflowBridge {
|
|
|
28
31
|
let in_cmds = self.incoming_commands.try_recv();
|
|
29
32
|
|
|
30
33
|
let in_cmds = in_cmds.unwrap_or_else(|_| vec![WFCommand::NoCommandsFromLang]);
|
|
31
|
-
debug!(in_cmds =
|
|
34
|
+
debug!(in_cmds = %in_cmds.display(), "wf bridge iteration fetch");
|
|
32
35
|
in_cmds
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
use crate::
|
|
1
|
+
use crate::workflow::WFCommand;
|
|
2
2
|
use std::collections::VecDeque;
|
|
3
3
|
use temporal_sdk_core_protos::{
|
|
4
4
|
coresdk::workflow_activation::{
|
|
5
|
-
|
|
5
|
+
workflow_activation_job, CancelWorkflow, SignalWorkflow, WorkflowActivationJob,
|
|
6
6
|
},
|
|
7
7
|
temporal::api::history::v1::WorkflowExecutionStartedEventAttributes,
|
|
8
8
|
};
|
|
@@ -13,7 +13,7 @@ pub struct DrivenWorkflow {
|
|
|
13
13
|
started_attrs: Option<WorkflowExecutionStartedEventAttributes>,
|
|
14
14
|
fetcher: Box<dyn WorkflowFetcher>,
|
|
15
15
|
/// Outgoing activation jobs that need to be sent to the lang sdk
|
|
16
|
-
outgoing_wf_activation_jobs: VecDeque<
|
|
16
|
+
outgoing_wf_activation_jobs: VecDeque<workflow_activation_job::Variant>,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
impl<WF> From<Box<WF>> for DrivenWorkflow
|
|
@@ -36,13 +36,23 @@ impl DrivenWorkflow {
|
|
|
36
36
|
self.started_attrs = Some(attribs);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/// Return the attributes from the workflow execution started event if this workflow has started
|
|
40
|
+
pub fn get_started_attrs(&self) -> Option<&WorkflowExecutionStartedEventAttributes> {
|
|
41
|
+
self.started_attrs.as_ref()
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
/// Enqueue a new job to be sent to the driven workflow
|
|
40
|
-
pub fn send_job(&mut self, job:
|
|
45
|
+
pub fn send_job(&mut self, job: workflow_activation_job::Variant) {
|
|
41
46
|
self.outgoing_wf_activation_jobs.push_back(job);
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
/// Check if there are pending jobs
|
|
50
|
+
pub fn has_pending_jobs(&self) -> bool {
|
|
51
|
+
!self.outgoing_wf_activation_jobs.is_empty()
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
/// Drain all pending jobs, so that they may be sent to the driven workflow
|
|
45
|
-
pub fn drain_jobs(&mut self) -> Vec<
|
|
55
|
+
pub fn drain_jobs(&mut self) -> Vec<WorkflowActivationJob> {
|
|
46
56
|
self.outgoing_wf_activation_jobs
|
|
47
57
|
.drain(..)
|
|
48
58
|
.map(Into::into)
|
|
@@ -51,12 +61,12 @@ impl DrivenWorkflow {
|
|
|
51
61
|
|
|
52
62
|
/// Signal the workflow
|
|
53
63
|
pub fn signal(&mut self, signal: SignalWorkflow) {
|
|
54
|
-
self.send_job(
|
|
64
|
+
self.send_job(workflow_activation_job::Variant::SignalWorkflow(signal));
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
/// Cancel the workflow
|
|
58
68
|
pub fn cancel(&mut self, attribs: CancelWorkflow) {
|
|
59
|
-
self.send_job(
|
|
69
|
+
self.send_job(workflow_activation_job::Variant::CancelWorkflow(attribs));
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
use crate::
|
|
1
|
+
use crate::{
|
|
2
|
+
replay::{HistoryInfo, TestHistoryBuilder},
|
|
3
|
+
ServerGatewayApis,
|
|
4
|
+
};
|
|
2
5
|
use futures::{future::BoxFuture, stream, stream::BoxStream, FutureExt, Stream, StreamExt};
|
|
3
6
|
use std::{
|
|
4
7
|
collections::VecDeque,
|
|
@@ -108,8 +111,14 @@ impl HistoryUpdate {
|
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
pub fn new_from_events
|
|
114
|
+
/// Create an instance of an update directly from events - should only be used for replaying.
|
|
115
|
+
pub fn new_from_events<I: IntoIterator<Item = HistoryEvent>>(
|
|
116
|
+
events: I,
|
|
117
|
+
previous_wft_started_id: i64,
|
|
118
|
+
) -> Self
|
|
119
|
+
where
|
|
120
|
+
<I as IntoIterator>::IntoIter: Send + 'static,
|
|
121
|
+
{
|
|
113
122
|
Self {
|
|
114
123
|
events: stream::iter(events.into_iter().map(Ok)).boxed(),
|
|
115
124
|
buffered: VecDeque::new(),
|
|
@@ -227,10 +236,27 @@ impl HistoryUpdate {
|
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
|
|
239
|
+
impl From<HistoryInfo> for HistoryUpdate {
|
|
240
|
+
fn from(v: HistoryInfo) -> Self {
|
|
241
|
+
Self::new_from_events(v.events().to_vec(), v.previous_started_event_id())
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
pub trait TestHBExt {
|
|
246
|
+
fn as_history_update(&self) -> HistoryUpdate;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
impl TestHBExt for TestHistoryBuilder {
|
|
250
|
+
fn as_history_update(&self) -> HistoryUpdate {
|
|
251
|
+
self.get_full_history_info().unwrap().into()
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
230
255
|
#[cfg(test)]
|
|
231
|
-
mod tests {
|
|
256
|
+
pub mod tests {
|
|
232
257
|
use super::*;
|
|
233
|
-
use crate::
|
|
258
|
+
use crate::test_help::canned_histories;
|
|
259
|
+
use temporal_client::mocks::mock_gateway;
|
|
234
260
|
|
|
235
261
|
#[tokio::test]
|
|
236
262
|
async fn consumes_standard_wft_sequence() {
|
|
@@ -285,8 +311,8 @@ mod tests {
|
|
|
285
311
|
let wft_count = 500;
|
|
286
312
|
let long_hist = canned_histories::long_sequential_timers(wft_count);
|
|
287
313
|
let initial_hist = long_hist.get_history_info(10).unwrap();
|
|
288
|
-
let prev_started = initial_hist.previous_started_event_id;
|
|
289
|
-
let mut mock_gateway =
|
|
314
|
+
let prev_started = initial_hist.previous_started_event_id();
|
|
315
|
+
let mut mock_gateway = mock_gateway();
|
|
290
316
|
|
|
291
317
|
let mut npt = 2;
|
|
292
318
|
mock_gateway
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#![allow(clippy::large_enum_variant)]
|
|
2
2
|
|
|
3
|
-
use
|
|
3
|
+
use super::{
|
|
4
4
|
workflow_machines::MachineResponse, Cancellable, EventInfo, MachineKind, NewMachineWithCommand,
|
|
5
5
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
6
6
|
};
|
|
@@ -8,7 +8,7 @@ use rustfsm::{fsm, MachineError, StateMachine, TransitionResult};
|
|
|
8
8
|
use std::convert::{TryFrom, TryInto};
|
|
9
9
|
use temporal_sdk_core_protos::{
|
|
10
10
|
coresdk::{
|
|
11
|
-
activity_result::{self as ar,
|
|
11
|
+
activity_result::{self as ar, activity_resolution, ActivityResolution, Cancellation},
|
|
12
12
|
common::Payload,
|
|
13
13
|
workflow_activation::ResolveActivity,
|
|
14
14
|
workflow_commands::{ActivityCancellationType, ScheduleActivity},
|
|
@@ -92,11 +92,11 @@ pub(super) enum ActivityMachineCommand {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/// Creates a new activity state machine and a command to schedule it on the server.
|
|
95
|
-
pub(super) fn new_activity(attribs: ScheduleActivity) -> NewMachineWithCommand
|
|
95
|
+
pub(super) fn new_activity(attribs: ScheduleActivity) -> NewMachineWithCommand {
|
|
96
96
|
let (activity, add_cmd) = ActivityMachine::new_scheduled(attribs);
|
|
97
97
|
NewMachineWithCommand {
|
|
98
98
|
command: add_cmd,
|
|
99
|
-
machine: activity,
|
|
99
|
+
machine: activity.into(),
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -136,8 +136,8 @@ impl ActivityMachine {
|
|
|
136
136
|
fn create_cancelation_resolve(&self, details: Option<Payload>) -> ResolveActivity {
|
|
137
137
|
ResolveActivity {
|
|
138
138
|
seq: self.shared_state.attrs.seq,
|
|
139
|
-
result: Some(
|
|
140
|
-
status: Some(
|
|
139
|
+
result: Some(ActivityResolution {
|
|
140
|
+
status: Some(activity_resolution::Status::Cancelled(Cancellation {
|
|
141
141
|
failure: Some(Failure {
|
|
142
142
|
message: "Activity cancelled".to_string(),
|
|
143
143
|
cause: Some(Box::from(Failure {
|
|
@@ -243,8 +243,8 @@ impl WFMachinesAdapter for ActivityMachine {
|
|
|
243
243
|
ActivityMachineCommand::Complete(result) => {
|
|
244
244
|
vec![ResolveActivity {
|
|
245
245
|
seq: self.shared_state.attrs.seq,
|
|
246
|
-
result: Some(
|
|
247
|
-
status: Some(
|
|
246
|
+
result: Some(ActivityResolution {
|
|
247
|
+
status: Some(activity_resolution::Status::Completed(ar::Success {
|
|
248
248
|
result: convert_payloads(event_info, result)?,
|
|
249
249
|
})),
|
|
250
250
|
}),
|
|
@@ -254,8 +254,8 @@ impl WFMachinesAdapter for ActivityMachine {
|
|
|
254
254
|
ActivityMachineCommand::Fail(failure) => {
|
|
255
255
|
vec![ResolveActivity {
|
|
256
256
|
seq: self.shared_state.attrs.seq,
|
|
257
|
-
result: Some(
|
|
258
|
-
status: Some(
|
|
257
|
+
result: Some(ActivityResolution {
|
|
258
|
+
status: Some(activity_resolution::Status::Failed(ar::Failure {
|
|
259
259
|
failure: Some(failure),
|
|
260
260
|
})),
|
|
261
261
|
}),
|
|
@@ -748,16 +748,16 @@ fn convert_payloads(
|
|
|
748
748
|
mod test {
|
|
749
749
|
use super::*;
|
|
750
750
|
use crate::{
|
|
751
|
-
|
|
752
|
-
ActivityOptions, CancellableFuture, WfContext, WorkflowFunction, WorkflowResult,
|
|
753
|
-
},
|
|
754
|
-
test_help::{canned_histories, TestHistoryBuilder},
|
|
751
|
+
replay::TestHistoryBuilder, test_help::canned_histories,
|
|
755
752
|
workflow::managed_wf::ManagedWFFunc,
|
|
756
753
|
};
|
|
757
754
|
use rstest::{fixture, rstest};
|
|
758
755
|
use std::mem::discriminant;
|
|
756
|
+
use temporal_sdk::{
|
|
757
|
+
ActivityOptions, CancellableFuture, WfContext, WorkflowFunction, WorkflowResult,
|
|
758
|
+
};
|
|
759
759
|
use temporal_sdk_core_protos::coresdk::workflow_activation::{
|
|
760
|
-
|
|
760
|
+
workflow_activation_job, WorkflowActivationJob,
|
|
761
761
|
};
|
|
762
762
|
|
|
763
763
|
#[fixture]
|
|
@@ -776,7 +776,7 @@ mod test {
|
|
|
776
776
|
ManagedWFFunc::new(t, func, vec![])
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
-
async fn activity_wf(
|
|
779
|
+
async fn activity_wf(command_sink: WfContext) -> WorkflowResult<()> {
|
|
780
780
|
command_sink.activity(ActivityOptions::default()).await;
|
|
781
781
|
Ok(().into())
|
|
782
782
|
}
|
|
@@ -789,7 +789,7 @@ mod test {
|
|
|
789
789
|
#[tokio::test]
|
|
790
790
|
async fn single_activity_inc(mut wfm: ManagedWFFunc) {
|
|
791
791
|
wfm.get_next_activation().await.unwrap();
|
|
792
|
-
let commands = wfm.get_server_commands().
|
|
792
|
+
let commands = wfm.get_server_commands().commands;
|
|
793
793
|
assert_eq!(commands.len(), 1);
|
|
794
794
|
assert_eq!(
|
|
795
795
|
commands[0].command_type,
|
|
@@ -797,7 +797,7 @@ mod test {
|
|
|
797
797
|
);
|
|
798
798
|
|
|
799
799
|
wfm.get_next_activation().await.unwrap();
|
|
800
|
-
let commands = wfm.get_server_commands().
|
|
800
|
+
let commands = wfm.get_server_commands().commands;
|
|
801
801
|
assert_eq!(commands.len(), 1);
|
|
802
802
|
assert_eq!(
|
|
803
803
|
commands[0].command_type,
|
|
@@ -814,7 +814,7 @@ mod test {
|
|
|
814
814
|
#[tokio::test]
|
|
815
815
|
async fn single_activity_full(mut wfm: ManagedWFFunc) {
|
|
816
816
|
wfm.process_all_activations().await.unwrap();
|
|
817
|
-
let commands = wfm.get_server_commands().
|
|
817
|
+
let commands = wfm.get_server_commands().commands;
|
|
818
818
|
assert_eq!(commands.len(), 1);
|
|
819
819
|
assert_eq!(
|
|
820
820
|
commands[0].command_type,
|
|
@@ -825,10 +825,10 @@ mod test {
|
|
|
825
825
|
|
|
826
826
|
#[tokio::test]
|
|
827
827
|
async fn immediate_activity_cancelation() {
|
|
828
|
-
let func = WorkflowFunction::new(|
|
|
828
|
+
let func = WorkflowFunction::new(|ctx: WfContext| async move {
|
|
829
829
|
let cancel_activity_future = ctx.activity(ActivityOptions::default());
|
|
830
830
|
// Immediately cancel the activity
|
|
831
|
-
cancel_activity_future.cancel(&
|
|
831
|
+
cancel_activity_future.cancel(&ctx);
|
|
832
832
|
cancel_activity_future.await;
|
|
833
833
|
Ok(().into())
|
|
834
834
|
});
|
|
@@ -840,14 +840,14 @@ mod test {
|
|
|
840
840
|
let mut wfm = ManagedWFFunc::new(t, func, vec![]);
|
|
841
841
|
|
|
842
842
|
let activation = wfm.process_all_activations().await.unwrap();
|
|
843
|
-
wfm.get_server_commands()
|
|
843
|
+
wfm.get_server_commands();
|
|
844
844
|
assert_matches!(
|
|
845
845
|
activation.jobs.as_slice(),
|
|
846
|
-
[
|
|
847
|
-
variant: Some(
|
|
846
|
+
[WorkflowActivationJob {
|
|
847
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
|
848
848
|
ResolveActivity {
|
|
849
|
-
result: Some(
|
|
850
|
-
status: Some(
|
|
849
|
+
result: Some(ActivityResolution {
|
|
850
|
+
status: Some(activity_resolution::Status::Cancelled(_))
|
|
851
851
|
}),
|
|
852
852
|
..
|
|
853
853
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use
|
|
1
|
+
use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, MachineKind, NewMachineWithCommand,
|
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
4
4
|
};
|
|
@@ -58,7 +58,7 @@ pub(super) fn new_external_cancel(
|
|
|
58
58
|
seq: u32,
|
|
59
59
|
workflow_execution: NamespacedWorkflowExecution,
|
|
60
60
|
only_child: bool,
|
|
61
|
-
) -> NewMachineWithCommand
|
|
61
|
+
) -> NewMachineWithCommand {
|
|
62
62
|
let mut s = CancelExternalMachine {
|
|
63
63
|
state: Created {}.into(),
|
|
64
64
|
shared_state: SharedState { seq },
|
|
@@ -81,7 +81,7 @@ pub(super) fn new_external_cancel(
|
|
|
81
81
|
};
|
|
82
82
|
NewMachineWithCommand {
|
|
83
83
|
command: cmd,
|
|
84
|
-
machine: s,
|
|
84
|
+
machine: s.into(),
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -230,13 +230,10 @@ impl Cancellable for CancelExternalMachine {}
|
|
|
230
230
|
#[cfg(test)]
|
|
231
231
|
mod tests {
|
|
232
232
|
use super::*;
|
|
233
|
-
use crate::{
|
|
234
|
-
|
|
235
|
-
test_help::TestHistoryBuilder,
|
|
236
|
-
workflow::managed_wf::ManagedWFFunc,
|
|
237
|
-
};
|
|
233
|
+
use crate::{replay::TestHistoryBuilder, workflow::managed_wf::ManagedWFFunc};
|
|
234
|
+
use temporal_sdk::{WfContext, WorkflowFunction, WorkflowResult};
|
|
238
235
|
|
|
239
|
-
async fn cancel_sender(
|
|
236
|
+
async fn cancel_sender(ctx: WfContext) -> WorkflowResult<()> {
|
|
240
237
|
let res = ctx
|
|
241
238
|
.cancel_external(NamespacedWorkflowExecution {
|
|
242
239
|
namespace: "some_namespace".to_string(),
|
|
@@ -275,14 +272,14 @@ mod tests {
|
|
|
275
272
|
let wff = WorkflowFunction::new(cancel_sender);
|
|
276
273
|
let mut wfm = ManagedWFFunc::new(t, wff, vec![]);
|
|
277
274
|
wfm.get_next_activation().await.unwrap();
|
|
278
|
-
let cmds = wfm.get_server_commands().
|
|
275
|
+
let cmds = wfm.get_server_commands().commands;
|
|
279
276
|
assert_eq!(cmds.len(), 1);
|
|
280
277
|
assert_eq!(
|
|
281
278
|
cmds[0].command_type(),
|
|
282
279
|
CommandType::RequestCancelExternalWorkflowExecution
|
|
283
280
|
);
|
|
284
281
|
wfm.get_next_activation().await.unwrap();
|
|
285
|
-
let cmds = wfm.get_server_commands().
|
|
282
|
+
let cmds = wfm.get_server_commands().commands;
|
|
286
283
|
assert_eq!(cmds.len(), 1);
|
|
287
284
|
if fails {
|
|
288
285
|
assert_eq!(cmds[0].command_type(), CommandType::FailWorkflowExecution);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
use
|
|
2
|
-
Cancellable, EventInfo, HistoryEvent, MachineKind,
|
|
3
|
-
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
1
|
+
use super::{
|
|
2
|
+
workflow_machines::MachineResponse, Cancellable, EventInfo, HistoryEvent, MachineKind,
|
|
3
|
+
NewMachineWithCommand, OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
4
4
|
};
|
|
5
5
|
use rustfsm::{fsm, TransitionResult};
|
|
6
6
|
use std::convert::TryFrom;
|
|
@@ -32,9 +32,7 @@ pub(super) enum CancelWorkflowMachineError {}
|
|
|
32
32
|
#[derive(Debug, derive_more::Display)]
|
|
33
33
|
pub(super) enum CancelWorkflowCommand {}
|
|
34
34
|
|
|
35
|
-
pub(super) fn cancel_workflow(
|
|
36
|
-
attribs: CancelWorkflowExecution,
|
|
37
|
-
) -> NewMachineWithCommand<CancelWorkflowMachine> {
|
|
35
|
+
pub(super) fn cancel_workflow(attribs: CancelWorkflowExecution) -> NewMachineWithCommand {
|
|
38
36
|
let mut machine = CancelWorkflowMachine {
|
|
39
37
|
state: Created {}.into(),
|
|
40
38
|
shared_state: (),
|
|
@@ -45,7 +43,10 @@ pub(super) fn cancel_workflow(
|
|
|
45
43
|
command_type: CommandType::CancelWorkflowExecution as i32,
|
|
46
44
|
attributes: Some(attribs.into()),
|
|
47
45
|
};
|
|
48
|
-
NewMachineWithCommand {
|
|
46
|
+
NewMachineWithCommand {
|
|
47
|
+
command,
|
|
48
|
+
machine: machine.into(),
|
|
49
|
+
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
#[derive(Default, Clone)]
|
|
@@ -121,17 +122,14 @@ impl Cancellable for CancelWorkflowMachine {}
|
|
|
121
122
|
#[cfg(test)]
|
|
122
123
|
mod tests {
|
|
123
124
|
use super::*;
|
|
124
|
-
use crate::{
|
|
125
|
-
prototype_rust_sdk::{WfContext, WfExitValue, WorkflowFunction, WorkflowResult},
|
|
126
|
-
test_help::canned_histories,
|
|
127
|
-
workflow::managed_wf::ManagedWFFunc,
|
|
128
|
-
};
|
|
125
|
+
use crate::{test_help::canned_histories, workflow::managed_wf::ManagedWFFunc};
|
|
129
126
|
use std::time::Duration;
|
|
127
|
+
use temporal_sdk::{WfContext, WfExitValue, WorkflowFunction, WorkflowResult};
|
|
130
128
|
use temporal_sdk_core_protos::coresdk::workflow_activation::{
|
|
131
|
-
|
|
129
|
+
workflow_activation_job, WorkflowActivationJob,
|
|
132
130
|
};
|
|
133
131
|
|
|
134
|
-
async fn wf_with_timer(
|
|
132
|
+
async fn wf_with_timer(ctx: WfContext) -> WorkflowResult<()> {
|
|
135
133
|
ctx.timer(Duration::from_millis(500)).await;
|
|
136
134
|
Ok(WfExitValue::Cancelled)
|
|
137
135
|
}
|
|
@@ -142,7 +140,7 @@ mod tests {
|
|
|
142
140
|
let t = canned_histories::timer_wf_cancel_req_cancelled("1");
|
|
143
141
|
let mut wfm = ManagedWFFunc::new(t, func, vec![]);
|
|
144
142
|
wfm.get_next_activation().await.unwrap();
|
|
145
|
-
let commands = wfm.get_server_commands().
|
|
143
|
+
let commands = wfm.get_server_commands().commands;
|
|
146
144
|
assert_eq!(commands.len(), 1);
|
|
147
145
|
assert_eq!(commands[0].command_type, CommandType::StartTimer as i32);
|
|
148
146
|
|
|
@@ -150,15 +148,15 @@ mod tests {
|
|
|
150
148
|
assert_matches!(
|
|
151
149
|
act.jobs.as_slice(),
|
|
152
150
|
[
|
|
153
|
-
|
|
154
|
-
variant: Some(
|
|
151
|
+
WorkflowActivationJob {
|
|
152
|
+
variant: Some(workflow_activation_job::Variant::FireTimer(_)),
|
|
155
153
|
},
|
|
156
|
-
|
|
157
|
-
variant: Some(
|
|
154
|
+
WorkflowActivationJob {
|
|
155
|
+
variant: Some(workflow_activation_job::Variant::CancelWorkflow(_)),
|
|
158
156
|
}
|
|
159
157
|
]
|
|
160
158
|
);
|
|
161
|
-
let commands = wfm.get_server_commands().
|
|
159
|
+
let commands = wfm.get_server_commands().commands;
|
|
162
160
|
assert_eq!(commands.len(), 1);
|
|
163
161
|
assert_eq!(
|
|
164
162
|
commands[0].command_type,
|
|
@@ -166,7 +164,7 @@ mod tests {
|
|
|
166
164
|
);
|
|
167
165
|
|
|
168
166
|
assert!(wfm.get_next_activation().await.unwrap().jobs.is_empty());
|
|
169
|
-
let commands = wfm.get_server_commands().
|
|
167
|
+
let commands = wfm.get_server_commands().commands;
|
|
170
168
|
assert_eq!(commands.len(), 0);
|
|
171
169
|
wfm.shutdown().await.unwrap();
|
|
172
170
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use
|
|
1
|
+
use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, MachineKind, NewMachineWithCommand,
|
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
4
4
|
};
|
|
@@ -305,13 +305,11 @@ pub(super) struct SharedState {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
/// Creates a new child workflow state machine and a command to start it on the server.
|
|
308
|
-
pub(super) fn new_child_workflow(
|
|
309
|
-
attribs: StartChildWorkflowExecution,
|
|
310
|
-
) -> NewMachineWithCommand<ChildWorkflowMachine> {
|
|
308
|
+
pub(super) fn new_child_workflow(attribs: StartChildWorkflowExecution) -> NewMachineWithCommand {
|
|
311
309
|
let (wf, add_cmd) = ChildWorkflowMachine::new_scheduled(attribs);
|
|
312
310
|
NewMachineWithCommand {
|
|
313
311
|
command: add_cmd,
|
|
314
|
-
machine: wf,
|
|
312
|
+
machine: wf.into(),
|
|
315
313
|
}
|
|
316
314
|
}
|
|
317
315
|
|
|
@@ -619,15 +617,15 @@ fn convert_payloads(
|
|
|
619
617
|
mod test {
|
|
620
618
|
use super::*;
|
|
621
619
|
use crate::{
|
|
622
|
-
|
|
623
|
-
CancellableFuture, ChildWorkflowOptions, WfContext, WorkflowFunction, WorkflowResult,
|
|
624
|
-
},
|
|
625
|
-
test_help::{canned_histories, TestHistoryBuilder},
|
|
620
|
+
replay::TestHistoryBuilder, test_help::canned_histories,
|
|
626
621
|
workflow::managed_wf::ManagedWFFunc,
|
|
627
622
|
};
|
|
628
623
|
use anyhow::anyhow;
|
|
629
624
|
use rstest::{fixture, rstest};
|
|
630
625
|
use std::mem::discriminant;
|
|
626
|
+
use temporal_sdk::{
|
|
627
|
+
CancellableFuture, ChildWorkflowOptions, WfContext, WorkflowFunction, WorkflowResult,
|
|
628
|
+
};
|
|
631
629
|
use temporal_sdk_core_protos::coresdk::{
|
|
632
630
|
child_workflow::child_workflow_result,
|
|
633
631
|
workflow_activation::resolve_child_workflow_execution_start::Status as StartStatus,
|
|
@@ -675,7 +673,7 @@ mod test {
|
|
|
675
673
|
ManagedWFFunc::new(t, func, vec![[Expectation::StartFailure as u8].into()])
|
|
676
674
|
}
|
|
677
675
|
|
|
678
|
-
async fn parent_wf(
|
|
676
|
+
async fn parent_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
679
677
|
let expectation = Expectation::try_from_u8(ctx.get_args()[0].data[0]).unwrap();
|
|
680
678
|
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
681
679
|
workflow_id: "child-id-1".to_string(),
|
|
@@ -683,7 +681,7 @@ mod test {
|
|
|
683
681
|
..Default::default()
|
|
684
682
|
});
|
|
685
683
|
|
|
686
|
-
let start_res = child.start(&
|
|
684
|
+
let start_res = child.start(&ctx).await;
|
|
687
685
|
match (expectation, &start_res.status) {
|
|
688
686
|
(Expectation::Success | Expectation::Failure, StartStatus::Succeeded(_)) => {}
|
|
689
687
|
(Expectation::StartFailure, StartStatus::Failed(_)) => return Ok(().into()),
|
|
@@ -709,7 +707,7 @@ mod test {
|
|
|
709
707
|
#[tokio::test]
|
|
710
708
|
async fn single_child_workflow_until_completion(mut wfm: ManagedWFFunc) {
|
|
711
709
|
wfm.get_next_activation().await.unwrap();
|
|
712
|
-
let commands = wfm.get_server_commands().
|
|
710
|
+
let commands = wfm.get_server_commands().commands;
|
|
713
711
|
assert_eq!(commands.len(), 1);
|
|
714
712
|
assert_eq!(
|
|
715
713
|
commands[0].command_type,
|
|
@@ -717,13 +715,13 @@ mod test {
|
|
|
717
715
|
);
|
|
718
716
|
|
|
719
717
|
wfm.get_next_activation().await.unwrap();
|
|
720
|
-
let commands = wfm.get_server_commands().
|
|
718
|
+
let commands = wfm.get_server_commands().commands;
|
|
721
719
|
// Workflow is activated because the child WF has started.
|
|
722
720
|
// It does not generate any commands, just waits for completion.
|
|
723
721
|
assert_eq!(commands.len(), 0);
|
|
724
722
|
|
|
725
723
|
wfm.get_next_activation().await.unwrap();
|
|
726
|
-
let commands = wfm.get_server_commands().
|
|
724
|
+
let commands = wfm.get_server_commands().commands;
|
|
727
725
|
assert_eq!(commands.len(), 1);
|
|
728
726
|
assert_eq!(
|
|
729
727
|
commands[0].command_type,
|
|
@@ -736,7 +734,7 @@ mod test {
|
|
|
736
734
|
#[tokio::test]
|
|
737
735
|
async fn single_child_workflow_start_fail(mut wfm: ManagedWFFunc) {
|
|
738
736
|
wfm.get_next_activation().await.unwrap();
|
|
739
|
-
let commands = wfm.get_server_commands().
|
|
737
|
+
let commands = wfm.get_server_commands().commands;
|
|
740
738
|
assert_eq!(commands.len(), 1);
|
|
741
739
|
assert_eq!(
|
|
742
740
|
commands[0].command_type,
|
|
@@ -744,7 +742,7 @@ mod test {
|
|
|
744
742
|
);
|
|
745
743
|
|
|
746
744
|
wfm.get_next_activation().await.unwrap();
|
|
747
|
-
let commands = wfm.get_server_commands().
|
|
745
|
+
let commands = wfm.get_server_commands().commands;
|
|
748
746
|
assert_eq!(commands.len(), 1);
|
|
749
747
|
assert_eq!(
|
|
750
748
|
commands[0].command_type,
|
|
@@ -753,15 +751,15 @@ mod test {
|
|
|
753
751
|
wfm.shutdown().await.unwrap();
|
|
754
752
|
}
|
|
755
753
|
|
|
756
|
-
async fn cancel_before_send_wf(
|
|
754
|
+
async fn cancel_before_send_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
757
755
|
let workflow_id = "child-id-1";
|
|
758
756
|
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
759
757
|
workflow_id: workflow_id.to_string(),
|
|
760
758
|
workflow_type: "child".to_string(),
|
|
761
759
|
..Default::default()
|
|
762
760
|
});
|
|
763
|
-
let start = child.start(&
|
|
764
|
-
start.cancel(&
|
|
761
|
+
let start = child.start(&ctx);
|
|
762
|
+
start.cancel(&ctx);
|
|
765
763
|
match start.await.status {
|
|
766
764
|
StartStatus::Cancelled(_) => Ok(().into()),
|
|
767
765
|
_ => Err(anyhow!("Unexpected start status")),
|
|
@@ -783,12 +781,12 @@ mod test {
|
|
|
783
781
|
#[tokio::test]
|
|
784
782
|
async fn single_child_workflow_cancel_before_sent(mut wfm: ManagedWFFunc) {
|
|
785
783
|
wfm.get_next_activation().await.unwrap();
|
|
786
|
-
let commands = wfm.get_server_commands().
|
|
784
|
+
let commands = wfm.get_server_commands().commands;
|
|
787
785
|
// Workflow starts and cancels the child workflow, no commands should be sent to server.
|
|
788
786
|
assert_eq!(commands.len(), 0);
|
|
789
787
|
|
|
790
788
|
wfm.get_next_activation().await.unwrap();
|
|
791
|
-
let commands = wfm.get_server_commands().
|
|
789
|
+
let commands = wfm.get_server_commands().commands;
|
|
792
790
|
assert_eq!(commands.len(), 1);
|
|
793
791
|
assert_eq!(
|
|
794
792
|
commands[0].command_type,
|