@temporalio/core-bridge 1.15.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +172 -70
- package/lib/native.d.ts +1 -1
- package/package.json +2 -2
- 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 +41 -30
- package/sdk-core/Cargo.toml +3 -0
- package/sdk-core/README.md +15 -9
- 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} +280 -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} +1 -1
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +61 -2
- 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/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/buf.yaml +0 -3
- 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 +1166 -770
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +1243 -750
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +4 -3
- 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 +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +16 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +64 -6
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +88 -33
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +4 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +5 -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 +3 -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 +122 -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 +5 -7
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +268 -223
- 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 +264 -4
- package/sdk-core/crates/common/src/worker.rs +68 -603
- 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 +757 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +45 -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 +57 -64
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +41 -35
- 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 +13 -15
- 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 +493 -26
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +4 -8
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +7 -7
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +41 -111
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +118 -19
- 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 +179 -196
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -280
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +6 -9
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- 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 +9 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +103 -81
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +7 -11
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1124 -229
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +145 -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 +13 -13
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +28 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- 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 +19 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +14 -18
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +4 -6
- 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 +241 -196
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +3 -5
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -64
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +298 -252
- 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 +16 -12
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +48 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +327 -255
- 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 +147 -126
- 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 -453
- 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 +360 -231
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +248 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -43
- 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 +428 -315
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -243
- 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 +101 -42
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -147
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1036
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -41
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +397 -238
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +414 -189
- 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 +154 -137
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -105
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -54
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +363 -226
- package/sdk-core/crates/sdk-core/tests/main.rs +17 -15
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +207 -152
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +65 -34
- 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 +7 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +14 -14
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +83 -74
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +9 -14
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +1 -2
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +13 -13
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +6 -6
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +3 -4
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +62 -75
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +205 -318
- package/src/metrics.rs +22 -30
- package/src/runtime.rs +4 -5
- package/src/worker.rs +16 -19
- package/ts/native.ts +1 -1
- 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/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,5 +1,5 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
MetricsContext,
|
|
2
|
+
MetricsContext, WorkerConfig,
|
|
3
3
|
telemetry::metrics::workflow_type,
|
|
4
4
|
worker::workflow::{
|
|
5
5
|
HistoryUpdate, LocalActivityRequestSink, PermittedWFT, RequestEvictMsg, RunBasics,
|
|
@@ -8,12 +8,9 @@ use crate::{
|
|
|
8
8
|
};
|
|
9
9
|
use lru::LruCache;
|
|
10
10
|
use std::{num::NonZeroUsize, rc::Rc, sync::Arc};
|
|
11
|
-
use temporalio_common::{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
temporal::api::workflowservice::v1::get_system_info_response,
|
|
15
|
-
},
|
|
16
|
-
worker::WorkerConfig,
|
|
11
|
+
use temporalio_common::protos::{
|
|
12
|
+
coresdk::workflow_activation::remove_from_cache::EvictionReason,
|
|
13
|
+
temporal::api::workflowservice::v1::get_system_info_response,
|
|
17
14
|
};
|
|
18
15
|
|
|
19
16
|
pub(super) struct RunCache {
|
|
@@ -2,6 +2,7 @@ use crate::{
|
|
|
2
2
|
abstractions::OwnedMeteredSemPermit,
|
|
3
3
|
protosext::ValidPollWFTQResponse,
|
|
4
4
|
worker::{
|
|
5
|
+
WorkflowSlotKind,
|
|
5
6
|
client::WorkerClient,
|
|
6
7
|
workflow::{
|
|
7
8
|
CacheMissFetchReq, HistoryUpdate, NextPageReq, PermittedWFT,
|
|
@@ -11,10 +12,7 @@ use crate::{
|
|
|
11
12
|
};
|
|
12
13
|
use futures_util::{FutureExt, Stream, StreamExt, stream, stream::PollNext};
|
|
13
14
|
use std::{future, sync::Arc};
|
|
14
|
-
use temporalio_common::{
|
|
15
|
-
protos::{TaskToken, coresdk::WorkflowSlotInfo},
|
|
16
|
-
worker::WorkflowSlotKind,
|
|
17
|
-
};
|
|
15
|
+
use temporalio_common::protos::{TaskToken, coresdk::WorkflowSlotInfo};
|
|
18
16
|
use tracing::Span;
|
|
19
17
|
|
|
20
18
|
/// Transforms incoming validated WFTs and history fetching requests into [PermittedWFT]s ready
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
MetricsContext,
|
|
2
|
+
MetricsContext, WorkerConfig,
|
|
3
3
|
abstractions::{MeteredPermitDealer, OwnedMeteredSemPermit},
|
|
4
4
|
pollers::{BoxedWFPoller, LongPollBuffer, Poller, WorkflowTaskOptions, WorkflowTaskPoller},
|
|
5
5
|
protosext::ValidPollWFTQResponse,
|
|
6
6
|
telemetry::metrics::{workflow_poller, workflow_sticky_poller},
|
|
7
|
-
worker::{client::WorkerClient, wft_poller_behavior},
|
|
7
|
+
worker::{WorkflowSlotKind, client::WorkerClient, wft_poller_behavior},
|
|
8
8
|
};
|
|
9
9
|
use crossbeam_utils::atomic::AtomicCell;
|
|
10
10
|
use futures_util::{Stream, stream};
|
|
11
11
|
use std::{
|
|
12
|
-
sync::{Arc, OnceLock},
|
|
12
|
+
sync::{Arc, OnceLock, atomic::AtomicBool},
|
|
13
13
|
time::SystemTime,
|
|
14
14
|
};
|
|
15
|
-
use temporalio_common::
|
|
16
|
-
protos::temporal::api::workflowservice::v1::PollWorkflowTaskQueueResponse,
|
|
17
|
-
worker::{WorkerConfig, WorkflowSlotKind},
|
|
18
|
-
};
|
|
15
|
+
use temporalio_common::protos::temporal::api::workflowservice::v1::PollWorkflowTaskQueueResponse;
|
|
19
16
|
use tokio::sync::watch;
|
|
20
17
|
use tokio_util::sync::CancellationToken;
|
|
21
18
|
|
|
@@ -29,6 +26,7 @@ pub(crate) fn make_wft_poller(
|
|
|
29
26
|
wft_slots: &MeteredPermitDealer<WorkflowSlotKind>,
|
|
30
27
|
last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
31
28
|
sticky_last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
29
|
+
graceful_poll_shutdown: Arc<AtomicBool>,
|
|
32
30
|
) -> impl Stream<
|
|
33
31
|
Item = Result<
|
|
34
32
|
(
|
|
@@ -62,6 +60,7 @@ pub(crate) fn make_wft_poller(
|
|
|
62
60
|
wft_poller_shared: wft_poller_shared.clone(),
|
|
63
61
|
},
|
|
64
62
|
last_successful_poll_time,
|
|
63
|
+
graceful_poll_shutdown.clone(),
|
|
65
64
|
);
|
|
66
65
|
let sticky_queue_poller = sticky_queue_name.as_ref().map(|sqn| {
|
|
67
66
|
let sticky_metrics = metrics.with_new_attrs([workflow_sticky_poller()]);
|
|
@@ -77,6 +76,7 @@ pub(crate) fn make_wft_poller(
|
|
|
77
76
|
}),
|
|
78
77
|
WorkflowTaskOptions { wft_poller_shared },
|
|
79
78
|
sticky_last_successful_poll_time,
|
|
79
|
+
graceful_poll_shutdown,
|
|
80
80
|
)
|
|
81
81
|
});
|
|
82
82
|
let wf_task_poll_buffer = Box::new(WorkflowTaskPoller::new(
|
|
@@ -258,11 +258,10 @@ mod tests {
|
|
|
258
258
|
use super::*;
|
|
259
259
|
use crate::{
|
|
260
260
|
abstractions::tests::fixed_size_permit_dealer, pollers::MockPermittedPollBuffer,
|
|
261
|
-
test_help::mock_poller,
|
|
261
|
+
test_help::mock_poller, worker::WorkflowSlotKind,
|
|
262
262
|
};
|
|
263
263
|
use futures_util::{StreamExt, pin_mut};
|
|
264
264
|
use std::sync::Arc;
|
|
265
|
-
use temporalio_common::worker::WorkflowSlotKind;
|
|
266
265
|
|
|
267
266
|
#[tokio::test]
|
|
268
267
|
async fn poll_timeouts_do_not_produce_responses() {
|
|
@@ -10,9 +10,7 @@ use crate::{
|
|
|
10
10
|
};
|
|
11
11
|
use futures_util::{Stream, StreamExt, stream, stream::PollNext};
|
|
12
12
|
use std::{collections::VecDeque, fmt::Debug, future, sync::Arc};
|
|
13
|
-
use temporalio_common::
|
|
14
|
-
errors::PollError, protos::coresdk::workflow_activation::remove_from_cache::EvictionReason,
|
|
15
|
-
};
|
|
13
|
+
use temporalio_common::protos::coresdk::workflow_activation::remove_from_cache::EvictionReason;
|
|
16
14
|
use tokio_util::sync::CancellationToken;
|
|
17
15
|
use tracing::{Level, Span};
|
|
18
16
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
use std::sync::Arc;
|
|
2
|
+
use temporalio_macros::activities;
|
|
3
|
+
use temporalio_sdk::activities::{ActivityContext, ActivityError};
|
|
4
|
+
|
|
5
|
+
pub struct MyActivities;
|
|
6
|
+
|
|
7
|
+
#[activities]
|
|
8
|
+
impl MyActivities {
|
|
9
|
+
#[activity]
|
|
10
|
+
pub async fn static_activity(
|
|
11
|
+
_ctx: ActivityContext,
|
|
12
|
+
_in: String,
|
|
13
|
+
) -> Result<String, ActivityError> {
|
|
14
|
+
Ok("Can be static".to_string())
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#[activity]
|
|
18
|
+
pub async fn activity(
|
|
19
|
+
self: Arc<Self>,
|
|
20
|
+
_ctx: ActivityContext,
|
|
21
|
+
_in: bool,
|
|
22
|
+
) -> Result<String, ActivityError> {
|
|
23
|
+
Ok("I'm done!".to_string())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#[activity]
|
|
27
|
+
pub async fn activity_arc_fully_qualified(
|
|
28
|
+
self: std::sync::Arc<Self>,
|
|
29
|
+
_ctx: ActivityContext,
|
|
30
|
+
_in: bool,
|
|
31
|
+
) -> Result<String, ActivityError> {
|
|
32
|
+
Ok("I'm done!".to_string())
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[activity]
|
|
36
|
+
pub fn sync_activity(_ctx: ActivityContext, _in: bool) -> Result<String, ActivityError> {
|
|
37
|
+
Ok("Sync activities are supported too".to_string())
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pub struct MyActivitiesStatic;
|
|
42
|
+
|
|
43
|
+
#[activities]
|
|
44
|
+
impl MyActivitiesStatic {
|
|
45
|
+
#[activity]
|
|
46
|
+
pub async fn static_activity(
|
|
47
|
+
_ctx: ActivityContext,
|
|
48
|
+
_in: String,
|
|
49
|
+
) -> Result<String, ActivityError> {
|
|
50
|
+
Ok("Can be static".to_string())
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fn main() {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
use temporalio_macros::activities;
|
|
2
|
+
|
|
3
|
+
pub struct BadActivities;
|
|
4
|
+
|
|
5
|
+
#[activities]
|
|
6
|
+
impl BadActivities {
|
|
7
|
+
#[activity]
|
|
8
|
+
pub async fn no_context(
|
|
9
|
+
&self,
|
|
10
|
+
_ctx: ActivityContext,
|
|
11
|
+
_in: String,
|
|
12
|
+
) -> Result<String, ActivityError> {
|
|
13
|
+
// This should fail because the self type is invalid.
|
|
14
|
+
Ok("bad".to_string())
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fn main() {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
use temporalio_macros::activities;
|
|
2
|
+
|
|
3
|
+
pub struct BadActivities;
|
|
4
|
+
|
|
5
|
+
#[activities]
|
|
6
|
+
impl BadActivities {
|
|
7
|
+
#[activity]
|
|
8
|
+
pub async fn no_context(_in: String) -> Result<String, ActivityError> {
|
|
9
|
+
// This should fail because there's no ActivityContext parameter
|
|
10
|
+
Ok("bad".to_string())
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fn main() {}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
error: Activity functions must have an ActivityContext parameter as either the first parameter, or the second after `self: Arc<Self>`.
|
|
2
|
+
--> tests/activities_trybuild/missing_context_fail.rs:8:29
|
|
3
|
+
|
|
|
4
|
+
8 | pub async fn no_context(_in: String) -> Result<String, ActivityError> {
|
|
5
|
+
| ^^^
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
use std::sync::Arc;
|
|
2
|
+
use temporalio_macros::activities;
|
|
3
|
+
use temporalio_sdk::activities::{ActivityContext, ActivityError};
|
|
4
|
+
|
|
5
|
+
pub struct MultiArgActivities;
|
|
6
|
+
|
|
7
|
+
#[activities]
|
|
8
|
+
impl MultiArgActivities {
|
|
9
|
+
#[activity]
|
|
10
|
+
pub async fn two_args(
|
|
11
|
+
_ctx: ActivityContext,
|
|
12
|
+
_a: String,
|
|
13
|
+
_b: i32,
|
|
14
|
+
) -> Result<String, ActivityError> {
|
|
15
|
+
Ok("done".to_string())
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#[activity]
|
|
19
|
+
pub async fn three_args(
|
|
20
|
+
_ctx: ActivityContext,
|
|
21
|
+
_a: String,
|
|
22
|
+
_b: i32,
|
|
23
|
+
_c: bool,
|
|
24
|
+
) -> Result<String, ActivityError> {
|
|
25
|
+
Ok("done".to_string())
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[activity]
|
|
29
|
+
pub async fn instance_two_args(
|
|
30
|
+
self: Arc<Self>,
|
|
31
|
+
_ctx: ActivityContext,
|
|
32
|
+
_a: String,
|
|
33
|
+
_b: i32,
|
|
34
|
+
) -> Result<String, ActivityError> {
|
|
35
|
+
Ok("done".to_string())
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#[activity]
|
|
39
|
+
pub fn sync_two_args(
|
|
40
|
+
_ctx: ActivityContext,
|
|
41
|
+
_a: String,
|
|
42
|
+
_b: i32,
|
|
43
|
+
) -> Result<String, ActivityError> {
|
|
44
|
+
Ok("done".to_string())
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fn main() {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
use temporalio_macros::activities;
|
|
2
|
+
use temporalio_sdk::activities::{ActivityContext, ActivityError};
|
|
3
|
+
|
|
4
|
+
pub struct SimpleActivities;
|
|
5
|
+
|
|
6
|
+
#[activities]
|
|
7
|
+
impl SimpleActivities {
|
|
8
|
+
#[activity]
|
|
9
|
+
pub async fn no_input_activity(_ctx: ActivityContext) -> Result<String, ActivityError> {
|
|
10
|
+
Ok("No input needed".to_string())
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fn main() {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
use temporalio_macros::activities;
|
|
2
|
+
use temporalio_sdk::activities::ActivityContext;
|
|
3
|
+
|
|
4
|
+
pub struct VoidActivities;
|
|
5
|
+
|
|
6
|
+
#[activities]
|
|
7
|
+
impl VoidActivities {
|
|
8
|
+
#[activity]
|
|
9
|
+
pub async fn no_return(_ctx: ActivityContext, _in: String) {
|
|
10
|
+
println!("Doing work...");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#[activity]
|
|
14
|
+
pub fn sync_no_return(_ctx: ActivityContext) {
|
|
15
|
+
println!("Sync work...");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fn main() {}
|
|
@@ -4,14 +4,23 @@ mod common;
|
|
|
4
4
|
mod shared_tests;
|
|
5
5
|
|
|
6
6
|
use common::get_cloud_client;
|
|
7
|
-
use temporalio_client::
|
|
7
|
+
use temporalio_client::{NamespacedClient, grpc::WorkflowService};
|
|
8
|
+
use temporalio_common::protos::temporal::api::workflowservice::v1::ListWorkflowExecutionsRequest;
|
|
9
|
+
use tonic::IntoRequest;
|
|
8
10
|
|
|
9
11
|
#[tokio::test]
|
|
10
12
|
async fn tls_test() {
|
|
11
|
-
let con = get_cloud_client().await;
|
|
12
|
-
con.list_workflow_executions(
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let mut con = get_cloud_client().await;
|
|
14
|
+
con.list_workflow_executions(
|
|
15
|
+
ListWorkflowExecutionsRequest {
|
|
16
|
+
namespace: con.namespace(),
|
|
17
|
+
page_size: 100,
|
|
18
|
+
..Default::default()
|
|
19
|
+
}
|
|
20
|
+
.into_request(),
|
|
21
|
+
)
|
|
22
|
+
.await
|
|
23
|
+
.unwrap();
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
#[tokio::test]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
use std::time::Duration;
|
|
2
|
+
use temporalio_common::{data_converters::RawValue, protos::DEFAULT_ACTIVITY_TYPE};
|
|
3
|
+
use temporalio_macros::activities;
|
|
4
|
+
use temporalio_sdk::activities::{ActivityContext, ActivityError};
|
|
5
|
+
use tokio::time::sleep;
|
|
6
|
+
|
|
7
|
+
pub(crate) struct StdActivities;
|
|
8
|
+
|
|
9
|
+
#[activities]
|
|
10
|
+
impl StdActivities {
|
|
11
|
+
#[activity]
|
|
12
|
+
pub(crate) async fn echo(_ctx: ActivityContext, e: String) -> Result<String, ActivityError> {
|
|
13
|
+
Ok(e)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/// Activity that does nothing and returns success
|
|
17
|
+
#[activity]
|
|
18
|
+
pub(crate) async fn no_op(_ctx: ActivityContext, _: ()) -> Result<(), ActivityError> {
|
|
19
|
+
Ok(())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// Also a no-op, but uses the default name from history construction to work with
|
|
23
|
+
/// canned histories. Returns RawValue so anything in the canned history will "deserialize"
|
|
24
|
+
/// properly.
|
|
25
|
+
#[activity(name = DEFAULT_ACTIVITY_TYPE)]
|
|
26
|
+
pub(crate) async fn default(_ctx: ActivityContext, _: ()) -> Result<RawValue, ActivityError> {
|
|
27
|
+
Ok(RawValue::empty())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// Activity that sleeps for provided duration. Name is overriden to provide compatibility with
|
|
31
|
+
/// some canned histories.
|
|
32
|
+
#[activity(name = "delay")]
|
|
33
|
+
pub(crate) async fn delay(
|
|
34
|
+
_ctx: ActivityContext,
|
|
35
|
+
duration: Duration,
|
|
36
|
+
) -> Result<(), ActivityError> {
|
|
37
|
+
sleep(duration).await;
|
|
38
|
+
Ok(())
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// Always fails
|
|
42
|
+
#[activity]
|
|
43
|
+
pub(crate) async fn always_fail(_ctx: ActivityContext) -> Result<(), ActivityError> {
|
|
44
|
+
Err(anyhow::anyhow!("Oh no I failed!").into())
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#[activity]
|
|
48
|
+
pub(crate) async fn concat(
|
|
49
|
+
_ctx: ActivityContext,
|
|
50
|
+
a: String,
|
|
51
|
+
b: String,
|
|
52
|
+
) -> Result<String, ActivityError> {
|
|
53
|
+
Ok(format!("{a}{b}"))
|
|
54
|
+
}
|
|
55
|
+
}
|