@temporalio/core-bridge 1.14.2-canary-release-testing.0 → 1.16.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 +794 -650
- package/bridge-macros/src/derive_tryintojs.rs +40 -0
- package/lib/native.d.ts +24 -3
- package/package.json +4 -4
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.github/workflows/per-pr.yml +6 -6
- package/sdk-core/AGENTS.md +42 -31
- package/sdk-core/Cargo.toml +4 -1
- package/sdk-core/README.md +19 -13
- package/sdk-core/crates/client/Cargo.toml +4 -0
- package/sdk-core/crates/client/README.md +139 -0
- package/sdk-core/crates/client/src/async_activity_handle.rs +297 -0
- package/sdk-core/crates/client/src/callback_based.rs +7 -0
- package/sdk-core/crates/client/src/errors.rs +294 -0
- package/sdk-core/crates/client/src/{raw.rs → grpc.rs} +370 -159
- package/sdk-core/crates/client/src/lib.rs +920 -1326
- package/sdk-core/crates/client/src/metrics.rs +24 -33
- package/sdk-core/crates/client/src/options_structs.rs +457 -0
- package/sdk-core/crates/client/src/replaceable.rs +5 -4
- package/sdk-core/crates/client/src/request_extensions.rs +8 -9
- package/sdk-core/crates/client/src/retry.rs +99 -54
- package/sdk-core/crates/client/src/{worker/mod.rs → worker.rs} +104 -29
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +62 -3
- package/sdk-core/crates/common/build.rs +742 -12
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/ci.yml +2 -0
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/create-release.yml +0 -5
- package/sdk-core/crates/common/protos/api_upstream/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/README.md +8 -0
- package/sdk-core/crates/common/protos/api_upstream/cmd/check-path-conflicts/main.go +137 -0
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv2.json +3329 -2647
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +2734 -708
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/activity/v1/message.proto +155 -3
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/command/v1/message.proto +26 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/common/v1/message.proto +8 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +27 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/activity.proto +81 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/event_type.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +15 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +63 -15
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/errordetails/v1/message.proto +8 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/history/v1/message.proto +111 -17
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +21 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +20 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/worker/v1/message.proto +4 -7
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflow/v1/message.proto +80 -22
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +347 -23
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +242 -43
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/core_interface.proto +15 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +9 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +8 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +22 -5
- package/sdk-core/crates/common/src/activity_definition.rs +20 -0
- package/sdk-core/crates/common/src/data_converters.rs +770 -0
- package/sdk-core/crates/common/src/envconfig.rs +5 -0
- package/sdk-core/crates/common/src/lib.rs +15 -211
- package/sdk-core/crates/common/src/payload_visitor.rs +648 -0
- package/sdk-core/crates/common/src/priority.rs +110 -0
- package/sdk-core/crates/common/src/protos/canned_histories.rs +19 -0
- package/sdk-core/crates/common/src/protos/history_builder.rs +45 -0
- package/sdk-core/crates/common/src/protos/history_info.rs +2 -0
- package/sdk-core/crates/common/src/protos/mod.rs +134 -27
- package/sdk-core/crates/common/src/protos/task_token.rs +3 -3
- package/sdk-core/crates/common/src/protos/utilities.rs +11 -0
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/log_export.rs +11 -16
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +272 -225
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/otel.rs +8 -13
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_meter.rs +49 -50
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_server.rs +2 -3
- package/sdk-core/crates/common/src/telemetry.rs +278 -19
- package/sdk-core/crates/common/src/worker.rs +68 -636
- package/sdk-core/crates/common/src/workflow_definition.rs +60 -0
- package/sdk-core/crates/macros/Cargo.toml +5 -1
- package/sdk-core/crates/macros/src/activities_definitions.rs +585 -0
- package/sdk-core/crates/macros/src/fsm_impl.rs +507 -0
- package/sdk-core/crates/macros/src/lib.rs +138 -512
- package/sdk-core/crates/macros/src/macro_utils.rs +106 -0
- package/sdk-core/crates/macros/src/workflow_definitions.rs +1224 -0
- package/sdk-core/crates/sdk/Cargo.toml +19 -6
- package/sdk-core/crates/sdk/README.md +415 -0
- package/sdk-core/crates/sdk/src/activities.rs +417 -0
- package/sdk-core/crates/sdk/src/interceptors.rs +1 -1
- package/sdk-core/crates/sdk/src/lib.rs +759 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +64 -35
- package/sdk-core/crates/sdk/src/workflow_context.rs +1033 -289
- package/sdk-core/crates/sdk/src/workflow_future.rs +277 -213
- package/sdk-core/crates/sdk/src/workflows.rs +711 -0
- package/sdk-core/crates/sdk-core/Cargo.toml +59 -65
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +45 -54
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +1 -1
- package/sdk-core/crates/sdk-core/src/abstractions.rs +6 -10
- package/sdk-core/crates/sdk-core/src/core_tests/activity_tasks.rs +6 -5
- package/sdk-core/crates/sdk-core/src/core_tests/mod.rs +22 -21
- package/sdk-core/crates/sdk-core/src/core_tests/queries.rs +21 -25
- package/sdk-core/crates/sdk-core/src/core_tests/replay_flag.rs +7 -10
- package/sdk-core/crates/sdk-core/src/core_tests/updates.rs +14 -17
- package/sdk-core/crates/sdk-core/src/core_tests/workers.rs +647 -27
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +46 -41
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +13 -16
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +60 -123
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +411 -32
- package/sdk-core/crates/sdk-core/src/protosext/mod.rs +2 -2
- package/sdk-core/crates/sdk-core/src/replay/mod.rs +14 -5
- package/sdk-core/crates/sdk-core/src/telemetry/metrics.rs +183 -198
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -281
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +35 -16
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- package/sdk-core/crates/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +1 -0
- package/sdk-core/crates/sdk-core/src/worker/activities/local_activities.rs +11 -14
- package/sdk-core/crates/sdk-core/src/worker/activities.rs +16 -19
- package/sdk-core/crates/sdk-core/src/worker/client/mocks.rs +11 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +104 -86
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +10 -14
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1175 -241
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +150 -23
- package/sdk-core/crates/sdk-core/src/worker/slot_provider.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/fixed_size.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/resource_based.rs +25 -27
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +64 -44
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +5 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +21 -22
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs +28 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +20 -41
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +50 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/run_cache.rs +4 -7
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_extraction.rs +2 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_poller.rs +8 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/workflow_stream.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/activities_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/basic_pass.rs +54 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.rs +18 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/multi_arg_pass.rs +48 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_input_pass.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_return_type_pass.rs +19 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +14 -5
- package/sdk-core/crates/sdk-core/tests/common/activity_functions.rs +55 -0
- package/sdk-core/crates/sdk-core/tests/common/mod.rs +281 -236
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +9 -14
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -66
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +306 -268
- package/sdk-core/crates/sdk-core/tests/integ_tests/async_activity_client_tests.rs +230 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/client_tests.rs +94 -57
- package/sdk-core/crates/sdk-core/tests/integ_tests/data_converter_tests.rs +381 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +37 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +49 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +447 -300
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +50 -45
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +157 -157
- package/sdk-core/crates/sdk-core/tests/integ_tests/queries_tests.rs +103 -89
- package/sdk-core/crates/sdk-core/tests/integ_tests/update_tests.rs +609 -463
- package/sdk-core/crates/sdk-core/tests/integ_tests/visibility_tests.rs +80 -62
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +389 -265
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +250 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -49
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_client_tests.rs +180 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/activities.rs +437 -327
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -58
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -30
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -251
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/client_interactions.rs +552 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +110 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -149
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -32
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1040
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -43
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +402 -245
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +343 -207
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/queries.rs +415 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/replay.rs +96 -36
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs +155 -140
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -113
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -44
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -48
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +365 -242
- package/sdk-core/crates/sdk-core/tests/main.rs +22 -16
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +233 -187
- package/sdk-core/crates/sdk-core/tests/runner.rs +4 -6
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +73 -27
- package/sdk-core/crates/sdk-core/tests/shared_tests/priority.rs +107 -84
- package/sdk-core/crates/sdk-core/tests/workflows_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/basic_pass.rs +49 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/minimal_pass.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +8 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +37 -26
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +180 -87
- package/sdk-core/crates/sdk-core-c-bridge/src/lib.rs +89 -5
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +10 -16
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +59 -67
- package/sdk-core/crates/sdk-core-c-bridge/src/testing.rs +10 -10
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +57 -22
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +108 -12
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +9 -52
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +74 -91
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +206 -289
- package/src/helpers/try_into_js.rs +88 -2
- package/src/metrics.rs +277 -35
- package/src/runtime.rs +94 -45
- package/src/testing.rs +9 -16
- package/src/worker.rs +86 -68
- package/ts/native.ts +39 -3
- package/sdk-core/crates/client/src/workflow_handle/mod.rs +0 -212
- package/sdk-core/crates/common/src/errors.rs +0 -85
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +0 -129
- package/sdk-core/crates/macros/LICENSE.txt +0 -21
- package/sdk-core/crates/sdk/src/activity_context.rs +0 -238
- package/sdk-core/crates/sdk/src/app_data.rs +0 -37
- package/sdk-core/crates/sdk-core/tests/integ_tests/activity_functions.rs +0 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
common::{CoreWfStarter, NAMESPACE},
|
|
3
|
-
integ_tests::activity_functions::echo,
|
|
4
|
-
};
|
|
5
|
-
use futures_util::StreamExt;
|
|
1
|
+
use crate::common::{CoreWfStarter, NAMESPACE, activity_functions::StdActivities};
|
|
6
2
|
use std::{
|
|
7
3
|
sync::{
|
|
8
4
|
Arc,
|
|
@@ -10,62 +6,73 @@ use std::{
|
|
|
10
6
|
},
|
|
11
7
|
time::Duration,
|
|
12
8
|
};
|
|
13
|
-
use temporalio_client::{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
use temporalio_client::{
|
|
10
|
+
WorkflowSignalOptions, WorkflowStartOptions, errors::WorkflowGetResultError,
|
|
11
|
+
grpc::WorkflowService,
|
|
12
|
+
};
|
|
13
|
+
use temporalio_common::protos::temporal::api::{
|
|
14
|
+
common::v1::WorkflowExecution, workflowservice::v1::ResetWorkflowExecutionRequest,
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
use temporalio_common::worker::WorkerTaskTypes;
|
|
22
|
-
use
|
|
18
|
+
use temporalio_macros::{workflow, workflow_methods};
|
|
19
|
+
use temporalio_sdk::{LocalActivityOptions, SyncWorkflowContext, WorkflowContext, WorkflowResult};
|
|
23
20
|
use tokio::sync::Notify;
|
|
24
21
|
use tonic::IntoRequest;
|
|
25
22
|
|
|
23
|
+
const POST_FAIL_SIG: &str = "post-fail";
|
|
26
24
|
const POST_RESET_SIG: &str = "post-reset";
|
|
27
25
|
|
|
26
|
+
#[workflow]
|
|
27
|
+
struct ResetMeWf {
|
|
28
|
+
notify: Arc<Notify>,
|
|
29
|
+
post_reset_received: bool,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[workflow_methods(factory_only)]
|
|
33
|
+
impl ResetMeWf {
|
|
34
|
+
#[run(name = "reset_me_wf")]
|
|
35
|
+
async fn run(ctx: &mut WorkflowContext<Self>) -> WorkflowResult<()> {
|
|
36
|
+
ctx.timer(Duration::from_secs(1)).await;
|
|
37
|
+
ctx.timer(Duration::from_secs(1)).await;
|
|
38
|
+
ctx.state(|wf| wf.notify.notify_one());
|
|
39
|
+
ctx.wait_condition(|s| s.post_reset_received).await;
|
|
40
|
+
Ok(())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#[signal(name = POST_RESET_SIG)]
|
|
44
|
+
fn post_reset(&mut self, _ctx: &mut SyncWorkflowContext<Self>) {
|
|
45
|
+
self.post_reset_received = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
#[tokio::test]
|
|
29
50
|
async fn reset_workflow() {
|
|
30
51
|
let wf_name = "reset_me_wf";
|
|
31
52
|
let mut starter = CoreWfStarter::new(wf_name);
|
|
32
|
-
starter
|
|
33
|
-
.worker_config
|
|
34
|
-
.task_types(WorkerTaskTypes::workflow_only());
|
|
53
|
+
starter.sdk_config.task_types = WorkerTaskTypes::workflow_only();
|
|
35
54
|
let mut worker = starter.worker().await;
|
|
36
55
|
worker.fetch_results = false;
|
|
37
|
-
let notify = Arc::new(Notify::new());
|
|
38
56
|
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ctx.timer(Duration::from_secs(1)).await;
|
|
45
|
-
ctx.timer(Duration::from_secs(1)).await;
|
|
46
|
-
// Tell outer scope to send the reset
|
|
47
|
-
notify.notify_one();
|
|
48
|
-
let _ = ctx
|
|
49
|
-
.make_signal_channel(POST_RESET_SIG)
|
|
50
|
-
.next()
|
|
51
|
-
.await
|
|
52
|
-
.unwrap();
|
|
53
|
-
Ok(().into())
|
|
54
|
-
}
|
|
57
|
+
let notify = Arc::new(Notify::new());
|
|
58
|
+
let notify_clone = notify.clone();
|
|
59
|
+
worker.register_workflow_with_factory(move || ResetMeWf {
|
|
60
|
+
notify: notify_clone.clone(),
|
|
61
|
+
post_reset_received: false,
|
|
55
62
|
});
|
|
56
63
|
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
let task_queue = starter.get_task_queue().to_owned();
|
|
65
|
+
let handle = worker
|
|
66
|
+
.submit_workflow(
|
|
67
|
+
ResetMeWf::run,
|
|
68
|
+
(),
|
|
69
|
+
WorkflowStartOptions::new(task_queue, wf_name).build(),
|
|
63
70
|
)
|
|
64
71
|
.await
|
|
65
72
|
.unwrap();
|
|
73
|
+
let run_id = handle.info().run_id.clone().unwrap();
|
|
66
74
|
|
|
67
75
|
let mut client = starter.get_client().await;
|
|
68
|
-
let client = Arc::make_mut(&mut client);
|
|
69
76
|
let resetter_fut = async {
|
|
70
77
|
notify.notified().await;
|
|
71
78
|
// Do the reset
|
|
@@ -75,7 +82,7 @@ async fn reset_workflow() {
|
|
|
75
82
|
namespace: NAMESPACE.to_owned(),
|
|
76
83
|
workflow_execution: Some(WorkflowExecution {
|
|
77
84
|
workflow_id: wf_name.to_owned(),
|
|
78
|
-
run_id
|
|
85
|
+
run_id,
|
|
79
86
|
}),
|
|
80
87
|
// End of first WFT
|
|
81
88
|
workflow_task_finish_event_id: 4,
|
|
@@ -88,24 +95,15 @@ async fn reset_workflow() {
|
|
|
88
95
|
.unwrap();
|
|
89
96
|
|
|
90
97
|
// Unblock the workflow by sending the signal. Run ID will have changed after reset so
|
|
91
|
-
// we
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"".to_owned(),
|
|
96
|
-
POST_RESET_SIG.to_owned(),
|
|
97
|
-
None,
|
|
98
|
-
None,
|
|
99
|
-
)
|
|
100
|
-
.await
|
|
101
|
-
.unwrap();
|
|
102
|
-
|
|
103
|
-
// Wait for the now-reset workflow to finish
|
|
104
|
-
client
|
|
105
|
-
.get_untyped_workflow_handle(wf_name.to_owned(), "")
|
|
106
|
-
.get_workflow_result(Default::default())
|
|
98
|
+
// we re-obtain handle.
|
|
99
|
+
let handle = client.get_workflow_handle::<reset_me_wf::Run>(wf_name.to_owned());
|
|
100
|
+
handle
|
|
101
|
+
.signal(ResetMeWf::post_reset, (), WorkflowSignalOptions::default())
|
|
107
102
|
.await
|
|
108
103
|
.unwrap();
|
|
104
|
+
|
|
105
|
+
// Wait for the now-reset workflow to finish
|
|
106
|
+
handle.get_result(Default::default()).await.unwrap();
|
|
109
107
|
starter.shutdown().await;
|
|
110
108
|
};
|
|
111
109
|
let run_fut = worker.run_until_done();
|
|
@@ -113,94 +111,115 @@ async fn reset_workflow() {
|
|
|
113
111
|
rr.unwrap();
|
|
114
112
|
}
|
|
115
113
|
|
|
114
|
+
#[workflow]
|
|
115
|
+
struct ResetRandomseedWf {
|
|
116
|
+
did_fail: Arc<AtomicBool>,
|
|
117
|
+
rand_seed: Arc<AtomicU64>,
|
|
118
|
+
notify: Arc<Notify>,
|
|
119
|
+
post_fail_received: bool,
|
|
120
|
+
post_reset_received: bool,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#[workflow_methods(factory_only)]
|
|
124
|
+
impl ResetRandomseedWf {
|
|
125
|
+
#[run(name = "reset_randomseed")]
|
|
126
|
+
async fn run(ctx: &mut WorkflowContext<Self>) -> WorkflowResult<()> {
|
|
127
|
+
let _ = ctx.state(|wf| {
|
|
128
|
+
wf.rand_seed.compare_exchange(
|
|
129
|
+
0,
|
|
130
|
+
ctx.random_seed(),
|
|
131
|
+
Ordering::Relaxed,
|
|
132
|
+
Ordering::Relaxed,
|
|
133
|
+
)
|
|
134
|
+
});
|
|
135
|
+
ctx.timer(Duration::from_millis(100)).await;
|
|
136
|
+
ctx.timer(Duration::from_millis(100)).await;
|
|
137
|
+
if ctx
|
|
138
|
+
.state(|wf| {
|
|
139
|
+
wf.did_fail
|
|
140
|
+
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
|
|
141
|
+
})
|
|
142
|
+
.is_ok()
|
|
143
|
+
{
|
|
144
|
+
ctx.state(|wf| wf.notify.notify_one());
|
|
145
|
+
panic!("Ahh");
|
|
146
|
+
}
|
|
147
|
+
if ctx.state(|wf| wf.rand_seed.load(Ordering::Relaxed)) == ctx.random_seed() {
|
|
148
|
+
ctx.timer(Duration::from_millis(100)).await;
|
|
149
|
+
} else {
|
|
150
|
+
ctx.start_local_activity(
|
|
151
|
+
StdActivities::echo,
|
|
152
|
+
"hi!".to_string(),
|
|
153
|
+
LocalActivityOptions::default(),
|
|
154
|
+
)
|
|
155
|
+
.await
|
|
156
|
+
.map_err(|e| anyhow::anyhow!("{e}"))?;
|
|
157
|
+
}
|
|
158
|
+
ctx.wait_condition(|s| s.post_fail_received).await;
|
|
159
|
+
ctx.state(|wf| wf.notify.notify_one());
|
|
160
|
+
ctx.wait_condition(|s| s.post_reset_received).await;
|
|
161
|
+
Ok(())
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#[signal(name = POST_FAIL_SIG)]
|
|
165
|
+
fn post_fail(&mut self, _ctx: &mut SyncWorkflowContext<Self>) {
|
|
166
|
+
self.post_fail_received = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#[signal(name = POST_RESET_SIG)]
|
|
170
|
+
fn post_reset(&mut self, _ctx: &mut SyncWorkflowContext<Self>) {
|
|
171
|
+
self.post_reset_received = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
116
175
|
#[tokio::test]
|
|
117
176
|
async fn reset_randomseed() {
|
|
118
177
|
let wf_name = "reset_randomseed";
|
|
119
178
|
let mut starter = CoreWfStarter::new(wf_name);
|
|
120
|
-
starter.
|
|
179
|
+
starter.sdk_config.task_types = WorkerTaskTypes {
|
|
121
180
|
enable_workflows: true,
|
|
122
181
|
enable_local_activities: true,
|
|
123
182
|
enable_remote_activities: false,
|
|
124
183
|
enable_nexus: true,
|
|
125
|
-
}
|
|
184
|
+
};
|
|
126
185
|
let mut worker = starter.worker().await;
|
|
127
186
|
worker.fetch_results = false;
|
|
128
|
-
let notify = Arc::new(Notify::new());
|
|
129
|
-
|
|
130
|
-
const POST_FAIL_SIG: &str = "post-fail";
|
|
131
|
-
static DID_FAIL: AtomicBool = AtomicBool::new(false);
|
|
132
|
-
static RAND_SEED: AtomicU64 = AtomicU64::new(0);
|
|
133
187
|
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// Make a couple workflow tasks
|
|
145
|
-
ctx.timer(Duration::from_millis(100)).await;
|
|
146
|
-
ctx.timer(Duration::from_millis(100)).await;
|
|
147
|
-
if DID_FAIL
|
|
148
|
-
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
|
|
149
|
-
.is_ok()
|
|
150
|
-
{
|
|
151
|
-
// Tell outer scope to send the post-task-failure-signal
|
|
152
|
-
notify.notify_one();
|
|
153
|
-
panic!("Ahh");
|
|
154
|
-
}
|
|
155
|
-
// Make a command that is one thing with the initial seed, but another after reset
|
|
156
|
-
if RAND_SEED.load(Ordering::Relaxed) == ctx.random_seed() {
|
|
157
|
-
ctx.timer(Duration::from_millis(100)).await;
|
|
158
|
-
} else {
|
|
159
|
-
ctx.local_activity(LocalActivityOptions {
|
|
160
|
-
activity_type: "echo".to_string(),
|
|
161
|
-
input: "hi!".as_json_payload().expect("serializes fine"),
|
|
162
|
-
..Default::default()
|
|
163
|
-
})
|
|
164
|
-
.await;
|
|
165
|
-
}
|
|
166
|
-
// Wait for the post-task-fail signal
|
|
167
|
-
let _ = ctx.make_signal_channel(POST_FAIL_SIG).next().await.unwrap();
|
|
168
|
-
// Tell outer scope to send the reset
|
|
169
|
-
notify.notify_one();
|
|
170
|
-
let _ = ctx
|
|
171
|
-
.make_signal_channel(POST_RESET_SIG)
|
|
172
|
-
.next()
|
|
173
|
-
.await
|
|
174
|
-
.unwrap();
|
|
175
|
-
Ok(().into())
|
|
176
|
-
}
|
|
188
|
+
let did_fail = Arc::new(AtomicBool::new(false));
|
|
189
|
+
let rand_seed = Arc::new(AtomicU64::new(0));
|
|
190
|
+
let notify = Arc::new(Notify::new());
|
|
191
|
+
let notify_clone = notify.clone();
|
|
192
|
+
worker.register_workflow_with_factory(move || ResetRandomseedWf {
|
|
193
|
+
did_fail: did_fail.clone(),
|
|
194
|
+
rand_seed: rand_seed.clone(),
|
|
195
|
+
notify: notify_clone.clone(),
|
|
196
|
+
post_fail_received: false,
|
|
197
|
+
post_reset_received: false,
|
|
177
198
|
});
|
|
178
|
-
worker.
|
|
179
|
-
|
|
180
|
-
let
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
199
|
+
worker.register_activities(StdActivities);
|
|
200
|
+
|
|
201
|
+
let task_queue = starter.get_task_queue().to_owned();
|
|
202
|
+
let handle = worker
|
|
203
|
+
.submit_workflow(
|
|
204
|
+
ResetRandomseedWf::run,
|
|
205
|
+
(),
|
|
206
|
+
WorkflowStartOptions::new(task_queue, wf_name).build(),
|
|
186
207
|
)
|
|
187
208
|
.await
|
|
188
209
|
.unwrap();
|
|
210
|
+
let run_id = handle.info().run_id.clone().unwrap();
|
|
189
211
|
|
|
190
212
|
let mut client = starter.get_client().await;
|
|
191
|
-
let client = Arc::make_mut(&mut client);
|
|
192
213
|
let client_fur = async {
|
|
193
214
|
notify.notified().await;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
.await
|
|
203
|
-
.unwrap();
|
|
215
|
+
handle
|
|
216
|
+
.signal(
|
|
217
|
+
ResetRandomseedWf::post_fail,
|
|
218
|
+
(),
|
|
219
|
+
WorkflowSignalOptions::default(),
|
|
220
|
+
)
|
|
221
|
+
.await
|
|
222
|
+
.unwrap();
|
|
204
223
|
notify.notified().await;
|
|
205
224
|
// Reset the workflow to be after first timer has fired
|
|
206
225
|
client
|
|
@@ -221,24 +240,20 @@ async fn reset_randomseed() {
|
|
|
221
240
|
.unwrap();
|
|
222
241
|
|
|
223
242
|
// Unblock the workflow by sending the signal. Run ID will have changed after reset so
|
|
224
|
-
// we
|
|
225
|
-
WorkflowClientTrait::signal_workflow_execution(
|
|
226
|
-
client,
|
|
227
|
-
wf_name.to_owned(),
|
|
228
|
-
"".to_owned(),
|
|
229
|
-
POST_RESET_SIG.to_owned(),
|
|
230
|
-
None,
|
|
231
|
-
None,
|
|
232
|
-
)
|
|
233
|
-
.await
|
|
234
|
-
.unwrap();
|
|
235
|
-
|
|
236
|
-
// Wait for the now-reset workflow to finish
|
|
243
|
+
// we re-obtain the handle.
|
|
237
244
|
client
|
|
238
|
-
.
|
|
239
|
-
.
|
|
245
|
+
.get_workflow_handle::<reset_randomseed_wf::Run>(wf_name.to_owned())
|
|
246
|
+
.signal(
|
|
247
|
+
ResetRandomseedWf::post_reset,
|
|
248
|
+
(),
|
|
249
|
+
WorkflowSignalOptions::default(),
|
|
250
|
+
)
|
|
240
251
|
.await
|
|
241
252
|
.unwrap();
|
|
253
|
+
|
|
254
|
+
// Wait for the now-reset workflow to finish
|
|
255
|
+
let result = handle.get_result(Default::default()).await;
|
|
256
|
+
assert_matches!(result, Err(WorkflowGetResultError::Terminated { .. }));
|
|
242
257
|
starter.shutdown().await;
|
|
243
258
|
};
|
|
244
259
|
let run_fut = worker.run_until_done();
|