@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,4 +1,4 @@
|
|
|
1
|
-
use
|
|
1
|
+
use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, MachineKind, NewMachineWithCommand,
|
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
4
4
|
};
|
|
@@ -7,8 +7,7 @@ use std::convert::{TryFrom, TryInto};
|
|
|
7
7
|
use temporal_sdk_core_protos::{
|
|
8
8
|
coresdk::{
|
|
9
9
|
child_workflow::{
|
|
10
|
-
self as wfr, child_workflow_result::Status as ChildWorkflowStatus,
|
|
11
|
-
ChildWorkflowCancellationType, ChildWorkflowResult,
|
|
10
|
+
self as wfr, child_workflow_result::Status as ChildWorkflowStatus, ChildWorkflowResult,
|
|
12
11
|
},
|
|
13
12
|
common::Payload,
|
|
14
13
|
workflow_activation::{
|
|
@@ -115,7 +114,6 @@ impl StartCommandCreated {
|
|
|
115
114
|
StartEventRecorded::default(),
|
|
116
115
|
SharedState {
|
|
117
116
|
initiated_event_id,
|
|
118
|
-
attrs: None, // Drop the attributes to avoid holding large payloads in memory
|
|
119
117
|
..state
|
|
120
118
|
},
|
|
121
119
|
)
|
|
@@ -303,19 +301,15 @@ pub(super) struct SharedState {
|
|
|
303
301
|
workflow_id: String,
|
|
304
302
|
run_id: String,
|
|
305
303
|
workflow_type: String,
|
|
306
|
-
cancellation_type: ChildWorkflowCancellationType,
|
|
307
304
|
cancelled_before_sent: bool,
|
|
308
|
-
attrs: Option<StartChildWorkflowExecution>,
|
|
309
305
|
}
|
|
310
306
|
|
|
311
307
|
/// Creates a new child workflow state machine and a command to start it on the server.
|
|
312
|
-
pub(super) fn new_child_workflow(
|
|
313
|
-
attribs: StartChildWorkflowExecution,
|
|
314
|
-
) -> NewMachineWithCommand<ChildWorkflowMachine> {
|
|
308
|
+
pub(super) fn new_child_workflow(attribs: StartChildWorkflowExecution) -> NewMachineWithCommand {
|
|
315
309
|
let (wf, add_cmd) = ChildWorkflowMachine::new_scheduled(attribs);
|
|
316
310
|
NewMachineWithCommand {
|
|
317
311
|
command: add_cmd,
|
|
318
|
-
machine: wf,
|
|
312
|
+
machine: wf.into(),
|
|
319
313
|
}
|
|
320
314
|
}
|
|
321
315
|
|
|
@@ -329,11 +323,6 @@ impl ChildWorkflowMachine {
|
|
|
329
323
|
workflow_id: attribs.workflow_id.clone(),
|
|
330
324
|
workflow_type: attribs.workflow_type.clone(),
|
|
331
325
|
namespace: attribs.namespace.clone(),
|
|
332
|
-
cancellation_type: ChildWorkflowCancellationType::from_i32(
|
|
333
|
-
attribs.cancellation_type,
|
|
334
|
-
)
|
|
335
|
-
.unwrap(),
|
|
336
|
-
attrs: Some(attribs.clone()),
|
|
337
326
|
..Default::default()
|
|
338
327
|
},
|
|
339
328
|
};
|
|
@@ -628,15 +617,15 @@ fn convert_payloads(
|
|
|
628
617
|
mod test {
|
|
629
618
|
use super::*;
|
|
630
619
|
use crate::{
|
|
631
|
-
|
|
632
|
-
CancellableFuture, ChildWorkflowOptions, WfContext, WorkflowFunction, WorkflowResult,
|
|
633
|
-
},
|
|
634
|
-
test_help::{canned_histories, TestHistoryBuilder},
|
|
620
|
+
replay::TestHistoryBuilder, test_help::canned_histories,
|
|
635
621
|
workflow::managed_wf::ManagedWFFunc,
|
|
636
622
|
};
|
|
637
623
|
use anyhow::anyhow;
|
|
638
624
|
use rstest::{fixture, rstest};
|
|
639
625
|
use std::mem::discriminant;
|
|
626
|
+
use temporal_sdk::{
|
|
627
|
+
CancellableFuture, ChildWorkflowOptions, WfContext, WorkflowFunction, WorkflowResult,
|
|
628
|
+
};
|
|
640
629
|
use temporal_sdk_core_protos::coresdk::{
|
|
641
630
|
child_workflow::child_workflow_result,
|
|
642
631
|
workflow_activation::resolve_child_workflow_execution_start::Status as StartStatus,
|
|
@@ -684,7 +673,7 @@ mod test {
|
|
|
684
673
|
ManagedWFFunc::new(t, func, vec![[Expectation::StartFailure as u8].into()])
|
|
685
674
|
}
|
|
686
675
|
|
|
687
|
-
async fn parent_wf(
|
|
676
|
+
async fn parent_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
688
677
|
let expectation = Expectation::try_from_u8(ctx.get_args()[0].data[0]).unwrap();
|
|
689
678
|
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
690
679
|
workflow_id: "child-id-1".to_string(),
|
|
@@ -692,7 +681,7 @@ mod test {
|
|
|
692
681
|
..Default::default()
|
|
693
682
|
});
|
|
694
683
|
|
|
695
|
-
let start_res = child.start(&
|
|
684
|
+
let start_res = child.start(&ctx).await;
|
|
696
685
|
match (expectation, &start_res.status) {
|
|
697
686
|
(Expectation::Success | Expectation::Failure, StartStatus::Succeeded(_)) => {}
|
|
698
687
|
(Expectation::StartFailure, StartStatus::Failed(_)) => return Ok(().into()),
|
|
@@ -718,7 +707,7 @@ mod test {
|
|
|
718
707
|
#[tokio::test]
|
|
719
708
|
async fn single_child_workflow_until_completion(mut wfm: ManagedWFFunc) {
|
|
720
709
|
wfm.get_next_activation().await.unwrap();
|
|
721
|
-
let commands = wfm.get_server_commands().
|
|
710
|
+
let commands = wfm.get_server_commands().commands;
|
|
722
711
|
assert_eq!(commands.len(), 1);
|
|
723
712
|
assert_eq!(
|
|
724
713
|
commands[0].command_type,
|
|
@@ -726,13 +715,13 @@ mod test {
|
|
|
726
715
|
);
|
|
727
716
|
|
|
728
717
|
wfm.get_next_activation().await.unwrap();
|
|
729
|
-
let commands = wfm.get_server_commands().
|
|
718
|
+
let commands = wfm.get_server_commands().commands;
|
|
730
719
|
// Workflow is activated because the child WF has started.
|
|
731
720
|
// It does not generate any commands, just waits for completion.
|
|
732
721
|
assert_eq!(commands.len(), 0);
|
|
733
722
|
|
|
734
723
|
wfm.get_next_activation().await.unwrap();
|
|
735
|
-
let commands = wfm.get_server_commands().
|
|
724
|
+
let commands = wfm.get_server_commands().commands;
|
|
736
725
|
assert_eq!(commands.len(), 1);
|
|
737
726
|
assert_eq!(
|
|
738
727
|
commands[0].command_type,
|
|
@@ -745,7 +734,7 @@ mod test {
|
|
|
745
734
|
#[tokio::test]
|
|
746
735
|
async fn single_child_workflow_start_fail(mut wfm: ManagedWFFunc) {
|
|
747
736
|
wfm.get_next_activation().await.unwrap();
|
|
748
|
-
let commands = wfm.get_server_commands().
|
|
737
|
+
let commands = wfm.get_server_commands().commands;
|
|
749
738
|
assert_eq!(commands.len(), 1);
|
|
750
739
|
assert_eq!(
|
|
751
740
|
commands[0].command_type,
|
|
@@ -753,7 +742,7 @@ mod test {
|
|
|
753
742
|
);
|
|
754
743
|
|
|
755
744
|
wfm.get_next_activation().await.unwrap();
|
|
756
|
-
let commands = wfm.get_server_commands().
|
|
745
|
+
let commands = wfm.get_server_commands().commands;
|
|
757
746
|
assert_eq!(commands.len(), 1);
|
|
758
747
|
assert_eq!(
|
|
759
748
|
commands[0].command_type,
|
|
@@ -762,15 +751,15 @@ mod test {
|
|
|
762
751
|
wfm.shutdown().await.unwrap();
|
|
763
752
|
}
|
|
764
753
|
|
|
765
|
-
async fn cancel_before_send_wf(
|
|
754
|
+
async fn cancel_before_send_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
766
755
|
let workflow_id = "child-id-1";
|
|
767
756
|
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
768
757
|
workflow_id: workflow_id.to_string(),
|
|
769
758
|
workflow_type: "child".to_string(),
|
|
770
759
|
..Default::default()
|
|
771
760
|
});
|
|
772
|
-
let start = child.start(&
|
|
773
|
-
start.cancel(&
|
|
761
|
+
let start = child.start(&ctx);
|
|
762
|
+
start.cancel(&ctx);
|
|
774
763
|
match start.await.status {
|
|
775
764
|
StartStatus::Cancelled(_) => Ok(().into()),
|
|
776
765
|
_ => Err(anyhow!("Unexpected start status")),
|
|
@@ -792,12 +781,12 @@ mod test {
|
|
|
792
781
|
#[tokio::test]
|
|
793
782
|
async fn single_child_workflow_cancel_before_sent(mut wfm: ManagedWFFunc) {
|
|
794
783
|
wfm.get_next_activation().await.unwrap();
|
|
795
|
-
let commands = wfm.get_server_commands().
|
|
784
|
+
let commands = wfm.get_server_commands().commands;
|
|
796
785
|
// Workflow starts and cancels the child workflow, no commands should be sent to server.
|
|
797
786
|
assert_eq!(commands.len(), 0);
|
|
798
787
|
|
|
799
788
|
wfm.get_next_activation().await.unwrap();
|
|
800
|
-
let commands = wfm.get_server_commands().
|
|
789
|
+
let commands = wfm.get_server_commands().commands;
|
|
801
790
|
assert_eq!(commands.len(), 1);
|
|
802
791
|
assert_eq!(
|
|
803
792
|
commands[0].command_type,
|
|
@@ -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
|
};
|
|
@@ -34,13 +34,11 @@ pub(super) enum CompleteWFCommand {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/// Complete a workflow
|
|
37
|
-
pub(super) fn complete_workflow(
|
|
38
|
-
attribs: CompleteWorkflowExecution,
|
|
39
|
-
) -> NewMachineWithCommand<CompleteWorkflowMachine> {
|
|
37
|
+
pub(super) fn complete_workflow(attribs: CompleteWorkflowExecution) -> NewMachineWithCommand {
|
|
40
38
|
let (machine, add_cmd) = CompleteWorkflowMachine::new_scheduled(attribs);
|
|
41
39
|
NewMachineWithCommand {
|
|
42
40
|
command: add_cmd,
|
|
43
|
-
machine,
|
|
41
|
+
machine: machine.into(),
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
|
package/sdk-core/{src → core/src/workflow}/machines/continue_as_new_workflow_state_machine.rs
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use
|
|
1
|
+
use super::{
|
|
2
2
|
Cancellable, EventInfo, HistoryEvent, MachineKind, MachineResponse, NewMachineWithCommand,
|
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
4
4
|
};
|
|
@@ -29,9 +29,7 @@ fsm! {
|
|
|
29
29
|
#[derive(Debug, derive_more::Display)]
|
|
30
30
|
pub(super) enum ContinueAsNewWorkflowCommand {}
|
|
31
31
|
|
|
32
|
-
pub(super) fn continue_as_new(
|
|
33
|
-
attribs: ContinueAsNewWorkflowExecution,
|
|
34
|
-
) -> NewMachineWithCommand<ContinueAsNewWorkflowMachine> {
|
|
32
|
+
pub(super) fn continue_as_new(attribs: ContinueAsNewWorkflowExecution) -> NewMachineWithCommand {
|
|
35
33
|
let mut machine = ContinueAsNewWorkflowMachine {
|
|
36
34
|
state: Created {}.into(),
|
|
37
35
|
shared_state: (),
|
|
@@ -42,7 +40,10 @@ pub(super) fn continue_as_new(
|
|
|
42
40
|
command_type: CommandType::ContinueAsNewWorkflowExecution as i32,
|
|
43
41
|
attributes: Some(attribs.into()),
|
|
44
42
|
};
|
|
45
|
-
NewMachineWithCommand {
|
|
43
|
+
NewMachineWithCommand {
|
|
44
|
+
command,
|
|
45
|
+
machine: machine.into(),
|
|
46
|
+
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
#[derive(Default, Clone)]
|
|
@@ -120,19 +121,18 @@ impl Cancellable for ContinueAsNewWorkflowMachine {}
|
|
|
120
121
|
#[cfg(test)]
|
|
121
122
|
mod tests {
|
|
122
123
|
use super::*;
|
|
123
|
-
use crate::{
|
|
124
|
-
prototype_rust_sdk::{WfContext, WfExitValue, WorkflowFunction, WorkflowResult},
|
|
125
|
-
test_help::canned_histories,
|
|
126
|
-
workflow::managed_wf::ManagedWFFunc,
|
|
127
|
-
};
|
|
124
|
+
use crate::{test_help::canned_histories, workflow::managed_wf::ManagedWFFunc};
|
|
128
125
|
use std::time::Duration;
|
|
126
|
+
use temporal_sdk::{WfContext, WfExitValue, WorkflowFunction, WorkflowResult};
|
|
129
127
|
|
|
130
|
-
async fn wf_with_timer(
|
|
128
|
+
async fn wf_with_timer(ctx: WfContext) -> WorkflowResult<()> {
|
|
131
129
|
ctx.timer(Duration::from_millis(500)).await;
|
|
132
|
-
Ok(WfExitValue::
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
Ok(WfExitValue::continue_as_new(
|
|
131
|
+
ContinueAsNewWorkflowExecution {
|
|
132
|
+
arguments: vec![[1].into()],
|
|
133
|
+
..Default::default()
|
|
134
|
+
},
|
|
135
|
+
))
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
#[tokio::test]
|
|
@@ -141,12 +141,12 @@ mod tests {
|
|
|
141
141
|
let t = canned_histories::timer_then_continue_as_new("1");
|
|
142
142
|
let mut wfm = ManagedWFFunc::new(t, func, vec![]);
|
|
143
143
|
wfm.get_next_activation().await.unwrap();
|
|
144
|
-
let commands = wfm.get_server_commands().
|
|
144
|
+
let commands = wfm.get_server_commands().commands;
|
|
145
145
|
assert_eq!(commands.len(), 1);
|
|
146
146
|
assert_eq!(commands[0].command_type, CommandType::StartTimer as i32);
|
|
147
147
|
|
|
148
148
|
wfm.get_next_activation().await.unwrap();
|
|
149
|
-
let commands = wfm.get_server_commands().
|
|
149
|
+
let commands = wfm.get_server_commands().commands;
|
|
150
150
|
assert_eq!(commands.len(), 1);
|
|
151
151
|
assert_eq!(
|
|
152
152
|
commands[0].command_type,
|
|
@@ -154,7 +154,7 @@ mod tests {
|
|
|
154
154
|
);
|
|
155
155
|
|
|
156
156
|
assert!(wfm.get_next_activation().await.unwrap().jobs.is_empty());
|
|
157
|
-
let commands = wfm.get_server_commands().
|
|
157
|
+
let commands = wfm.get_server_commands().commands;
|
|
158
158
|
assert_eq!(commands.len(), 0);
|
|
159
159
|
wfm.shutdown().await.unwrap();
|
|
160
160
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
use
|
|
1
|
+
use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, MachineKind, NewMachineWithCommand,
|
|
3
|
-
OnEventWrapper,
|
|
3
|
+
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
4
4
|
};
|
|
5
5
|
use rustfsm::{fsm, TransitionResult};
|
|
6
6
|
use std::convert::TryFrom;
|
|
7
7
|
use temporal_sdk_core_protos::{
|
|
8
8
|
coresdk::workflow_commands::FailWorkflowExecution,
|
|
9
9
|
temporal::api::{
|
|
10
|
+
command::v1::Command as ProtoCommand,
|
|
10
11
|
enums::v1::{CommandType, EventType},
|
|
11
12
|
history::v1::HistoryEvent,
|
|
12
13
|
},
|
|
@@ -30,13 +31,11 @@ pub(super) enum FailWFCommand {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/// Fail a workflow
|
|
33
|
-
pub(super) fn fail_workflow(
|
|
34
|
-
attribs: FailWorkflowExecution,
|
|
35
|
-
) -> NewMachineWithCommand<FailWorkflowMachine> {
|
|
34
|
+
pub(super) fn fail_workflow(attribs: FailWorkflowExecution) -> NewMachineWithCommand {
|
|
36
35
|
let (machine, add_cmd) = FailWorkflowMachine::new_scheduled(attribs);
|
|
37
36
|
NewMachineWithCommand {
|
|
38
37
|
command: add_cmd,
|
|
39
|
-
machine,
|
|
38
|
+
machine: machine.into(),
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|