@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
|
@@ -62,12 +62,15 @@ pub const DEFAULT_CONFIG_FILE: &str = "temporal.toml";
|
|
|
62
62
|
/// Errors that can occur during configuration loading
|
|
63
63
|
#[derive(Debug, Error)]
|
|
64
64
|
pub enum ConfigError {
|
|
65
|
+
/// The requested profile was not found in the configuration.
|
|
65
66
|
#[error("Profile '{0}' not found")]
|
|
66
67
|
ProfileNotFound(String),
|
|
67
68
|
|
|
69
|
+
/// The configuration is invalid (e.g. conflicting options).
|
|
68
70
|
#[error("Invalid configuration: {0}")]
|
|
69
71
|
InvalidConfig(String),
|
|
70
72
|
|
|
73
|
+
/// An I/O or parsing error occurred while loading configuration.
|
|
71
74
|
#[error("Configuration loading error: {0}")]
|
|
72
75
|
LoadError(Box<dyn std::error::Error>),
|
|
73
76
|
}
|
|
@@ -99,7 +102,9 @@ impl From<toml::ser::Error> for ConfigError {
|
|
|
99
102
|
/// A source for configuration or a TLS certificate/key, from a path or raw data.
|
|
100
103
|
#[derive(Debug, Clone, PartialEq)]
|
|
101
104
|
pub enum DataSource {
|
|
105
|
+
/// A filesystem path to the data.
|
|
102
106
|
Path(String),
|
|
107
|
+
/// The raw data bytes.
|
|
103
108
|
Data(Vec<u8>),
|
|
104
109
|
}
|
|
105
110
|
|
|
@@ -1,226 +1,30 @@
|
|
|
1
|
+
#![warn(missing_docs)] // error if there are missing docs
|
|
2
|
+
|
|
1
3
|
//! This crate contains base-level functionality needed by the other crates in the Temporal Core and
|
|
2
4
|
//! Rust SDK.
|
|
3
5
|
|
|
6
|
+
#[allow(unused_imports)] // Not used by all flag combinations, which is fine.
|
|
7
|
+
#[macro_use]
|
|
8
|
+
extern crate tracing;
|
|
9
|
+
|
|
10
|
+
mod activity_definition;
|
|
11
|
+
pub mod data_converters;
|
|
4
12
|
#[cfg(feature = "envconfig")]
|
|
5
13
|
pub mod envconfig;
|
|
6
|
-
pub mod errors;
|
|
7
14
|
#[doc(hidden)]
|
|
8
15
|
pub mod fsm_trait;
|
|
16
|
+
pub mod payload_visitor;
|
|
17
|
+
mod priority;
|
|
9
18
|
pub mod protos;
|
|
10
19
|
pub mod telemetry;
|
|
11
20
|
pub mod worker;
|
|
21
|
+
mod workflow_definition;
|
|
12
22
|
|
|
13
|
-
use
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
protos::coresdk::{
|
|
19
|
-
ActivityHeartbeat, ActivityTaskCompletion, NamespaceInfo,
|
|
20
|
-
activity_task::ActivityTask,
|
|
21
|
-
nexus::{NexusTask, NexusTaskCompletion},
|
|
22
|
-
workflow_activation::WorkflowActivation,
|
|
23
|
-
workflow_completion::WorkflowActivationCompletion,
|
|
24
|
-
},
|
|
25
|
-
worker::WorkerConfig,
|
|
23
|
+
pub use activity_definition::ActivityDefinition;
|
|
24
|
+
pub use priority::Priority;
|
|
25
|
+
pub use workflow_definition::{
|
|
26
|
+
QueryDefinition, SignalDefinition, UpdateDefinition, WorkflowDefinition,
|
|
26
27
|
};
|
|
27
|
-
use std::sync::Arc;
|
|
28
|
-
use uuid::Uuid;
|
|
29
|
-
|
|
30
|
-
/// This trait is the primary way by which language specific SDKs interact with the core SDK.
|
|
31
|
-
/// It represents one worker, which has a (potentially shared) client for connecting to the service
|
|
32
|
-
/// and is bound to a specific task queue.
|
|
33
|
-
#[async_trait::async_trait]
|
|
34
|
-
pub trait Worker: Send + Sync {
|
|
35
|
-
/// Validate that the worker can properly connect to server, plus any other validation that
|
|
36
|
-
/// needs to be done asynchronously. Lang SDKs should call this function once before calling
|
|
37
|
-
/// any others.
|
|
38
|
-
async fn validate(&self) -> Result<NamespaceInfo, WorkerValidationError>;
|
|
39
|
-
|
|
40
|
-
/// Ask the worker for some work, returning a [WorkflowActivation]. It is then the language
|
|
41
|
-
/// SDK's responsibility to call the appropriate workflow code with the provided inputs. Blocks
|
|
42
|
-
/// indefinitely until such work is available or [Worker::shutdown] is called.
|
|
43
|
-
///
|
|
44
|
-
/// It is important to understand that all activations must be responded to. There can only
|
|
45
|
-
/// be one outstanding activation for a particular run of a workflow at any time. If an
|
|
46
|
-
/// activation is not responded to, it will cause that workflow to become stuck forever.
|
|
47
|
-
///
|
|
48
|
-
/// See [WorkflowActivation] for more details on the expected behavior of lang w.r.t activation
|
|
49
|
-
/// & job processing.
|
|
50
|
-
///
|
|
51
|
-
/// Do not call poll concurrently. It handles polling the server concurrently internally.
|
|
52
|
-
async fn poll_workflow_activation(&self) -> Result<WorkflowActivation, PollError>;
|
|
53
|
-
|
|
54
|
-
/// Ask the worker for some work, returning an [ActivityTask]. It is then the language SDK's
|
|
55
|
-
/// responsibility to call the appropriate activity code with the provided inputs. Blocks
|
|
56
|
-
/// indefinitely until such work is available or [Worker::shutdown] is called.
|
|
57
|
-
///
|
|
58
|
-
/// Do not call poll concurrently. It handles polling the server concurrently internally.
|
|
59
|
-
async fn poll_activity_task(&self) -> Result<ActivityTask, PollError>;
|
|
60
|
-
|
|
61
|
-
/// Ask the worker for some nexus related work. It is then the language SDK's
|
|
62
|
-
/// responsibility to call the appropriate nexus operation handler code with the provided
|
|
63
|
-
/// inputs. Blocks indefinitely until such work is available or [Worker::shutdown] is called.
|
|
64
|
-
///
|
|
65
|
-
/// All tasks must be responded to for shutdown to complete.
|
|
66
|
-
///
|
|
67
|
-
/// Do not call poll concurrently. It handles polling the server concurrently internally.
|
|
68
|
-
async fn poll_nexus_task(&self) -> Result<NexusTask, PollError>;
|
|
69
|
-
|
|
70
|
-
/// Tell the worker that a workflow activation has completed. May (and should) be freely called
|
|
71
|
-
/// concurrently. The future may take some time to resolve, as fetching more events might be
|
|
72
|
-
/// necessary for completion to... complete - thus SDK implementers should make sure they do
|
|
73
|
-
/// not serialize completions.
|
|
74
|
-
async fn complete_workflow_activation(
|
|
75
|
-
&self,
|
|
76
|
-
completion: WorkflowActivationCompletion,
|
|
77
|
-
) -> Result<(), CompleteWfError>;
|
|
78
|
-
|
|
79
|
-
/// Tell the worker that an activity has finished executing. May (and should) be freely called
|
|
80
|
-
/// concurrently.
|
|
81
|
-
async fn complete_activity_task(
|
|
82
|
-
&self,
|
|
83
|
-
completion: ActivityTaskCompletion,
|
|
84
|
-
) -> Result<(), CompleteActivityError>;
|
|
85
|
-
|
|
86
|
-
/// Tell the worker that a nexus task has completed. May (and should) be freely called
|
|
87
|
-
/// concurrently.
|
|
88
|
-
async fn complete_nexus_task(
|
|
89
|
-
&self,
|
|
90
|
-
completion: NexusTaskCompletion,
|
|
91
|
-
) -> Result<(), CompleteNexusError>;
|
|
92
|
-
|
|
93
|
-
/// Notify the Temporal service that an activity is still alive. Long running activities that
|
|
94
|
-
/// take longer than `activity_heartbeat_timeout` to finish must call this function in order to
|
|
95
|
-
/// report progress, otherwise the activity will timeout and a new attempt will be scheduled.
|
|
96
|
-
///
|
|
97
|
-
/// The first heartbeat request will be sent immediately, subsequent rapid calls to this
|
|
98
|
-
/// function will result in heartbeat requests being aggregated and the last one received during
|
|
99
|
-
/// the aggregation period will be sent to the server, where that period is defined as half the
|
|
100
|
-
/// heartbeat timeout.
|
|
101
|
-
///
|
|
102
|
-
/// Unlike Java/Go SDKs we do not return cancellation status as part of heartbeat response and
|
|
103
|
-
/// instead send it as a separate activity task to the lang, decoupling heartbeat and
|
|
104
|
-
/// cancellation processing.
|
|
105
|
-
///
|
|
106
|
-
/// For now activity still need to send heartbeats if they want to receive cancellation
|
|
107
|
-
/// requests. In the future we will change this and will dispatch cancellations more
|
|
108
|
-
/// proactively. Note that this function does not block on the server call and returns
|
|
109
|
-
/// immediately. Underlying validation errors are swallowed and logged, this has been agreed to
|
|
110
|
-
/// be optimal behavior for the user as we don't want to break activity execution due to badly
|
|
111
|
-
/// configured heartbeat options.
|
|
112
|
-
fn record_activity_heartbeat(&self, details: ActivityHeartbeat);
|
|
113
|
-
|
|
114
|
-
/// Request that a workflow be evicted by its run id. This will generate a workflow activation
|
|
115
|
-
/// with the eviction job inside it to be eventually returned by
|
|
116
|
-
/// [Worker::poll_workflow_activation]. If the workflow had any existing outstanding activations,
|
|
117
|
-
/// such activations are invalidated and subsequent completions of them will do nothing and log
|
|
118
|
-
/// a warning.
|
|
119
|
-
fn request_workflow_eviction(&self, run_id: &str);
|
|
120
|
-
|
|
121
|
-
/// Return this worker's config
|
|
122
|
-
fn get_config(&self) -> &WorkerConfig;
|
|
123
|
-
|
|
124
|
-
/// Initiate shutdown. See [Worker::shutdown], this is just a sync version that starts the
|
|
125
|
-
/// process. You can then wait on `shutdown` or [Worker::finalize_shutdown].
|
|
126
|
-
fn initiate_shutdown(&self);
|
|
127
|
-
|
|
128
|
-
/// Initiates async shutdown procedure, eventually ceases all polling of the server and shuts
|
|
129
|
-
/// down this worker. [Worker::poll_workflow_activation] and [Worker::poll_activity_task] should
|
|
130
|
-
/// be called until both return a `ShutDown` error to ensure that all outstanding work is
|
|
131
|
-
/// complete. This means that the lang sdk will need to call
|
|
132
|
-
/// [Worker::complete_workflow_activation] and [Worker::complete_activity_task] for those
|
|
133
|
-
/// workflows & activities until they are done. At that point, the lang SDK can end the process,
|
|
134
|
-
/// or drop the [Worker] instance via [Worker::finalize_shutdown], which will close the
|
|
135
|
-
/// connection and free resources. If you have set [WorkerConfig::task_types] to exclude
|
|
136
|
-
/// [worker::WorkerTaskTypes::activity_only()], you may skip calling [Worker::poll_activity_task].
|
|
137
|
-
///
|
|
138
|
-
/// Lang implementations should use [Worker::initiate_shutdown] followed by
|
|
139
|
-
/// [Worker::finalize_shutdown].
|
|
140
|
-
async fn shutdown(&self);
|
|
141
|
-
|
|
142
|
-
/// Completes shutdown and frees all resources. You should avoid simply dropping workers, as
|
|
143
|
-
/// this does not allow async tasks to report any panics that may have occurred cleanly.
|
|
144
|
-
///
|
|
145
|
-
/// This should be called only after [Worker::shutdown] has resolved and/or both polling
|
|
146
|
-
/// functions have returned `ShutDown` errors.
|
|
147
|
-
async fn finalize_shutdown(self);
|
|
148
|
-
|
|
149
|
-
/// Unique identifier for this worker instance.
|
|
150
|
-
/// This must be stable across the worker's lifetime and unique per instance.
|
|
151
|
-
fn worker_instance_key(&self) -> Uuid;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
#[async_trait::async_trait]
|
|
155
|
-
impl<W> Worker for Arc<W>
|
|
156
|
-
where
|
|
157
|
-
W: Worker + ?Sized,
|
|
158
|
-
{
|
|
159
|
-
async fn validate(&self) -> Result<NamespaceInfo, WorkerValidationError> {
|
|
160
|
-
(**self).validate().await
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async fn poll_workflow_activation(&self) -> Result<WorkflowActivation, PollError> {
|
|
164
|
-
(**self).poll_workflow_activation().await
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async fn poll_activity_task(&self) -> Result<ActivityTask, PollError> {
|
|
168
|
-
(**self).poll_activity_task().await
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async fn poll_nexus_task(&self) -> Result<NexusTask, PollError> {
|
|
172
|
-
(**self).poll_nexus_task().await
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async fn complete_workflow_activation(
|
|
176
|
-
&self,
|
|
177
|
-
completion: WorkflowActivationCompletion,
|
|
178
|
-
) -> Result<(), CompleteWfError> {
|
|
179
|
-
(**self).complete_workflow_activation(completion).await
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async fn complete_activity_task(
|
|
183
|
-
&self,
|
|
184
|
-
completion: ActivityTaskCompletion,
|
|
185
|
-
) -> Result<(), CompleteActivityError> {
|
|
186
|
-
(**self).complete_activity_task(completion).await
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async fn complete_nexus_task(
|
|
190
|
-
&self,
|
|
191
|
-
completion: NexusTaskCompletion,
|
|
192
|
-
) -> Result<(), CompleteNexusError> {
|
|
193
|
-
(**self).complete_nexus_task(completion).await
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
fn record_activity_heartbeat(&self, details: ActivityHeartbeat) {
|
|
197
|
-
(**self).record_activity_heartbeat(details)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
fn request_workflow_eviction(&self, run_id: &str) {
|
|
201
|
-
(**self).request_workflow_eviction(run_id)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
fn get_config(&self) -> &WorkerConfig {
|
|
205
|
-
(**self).get_config()
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
fn initiate_shutdown(&self) {
|
|
209
|
-
(**self).initiate_shutdown()
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async fn shutdown(&self) {
|
|
213
|
-
(**self).shutdown().await
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async fn finalize_shutdown(self) {
|
|
217
|
-
panic!("Can't finalize shutdown on Arc'd worker")
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
fn worker_instance_key(&self) -> Uuid {
|
|
221
|
-
(**self).worker_instance_key()
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
28
|
|
|
225
29
|
macro_rules! dbg_panic {
|
|
226
30
|
($($arg:tt)*) => {
|