@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
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
//! that will match the generated structs in this module.
|
|
4
4
|
|
|
5
5
|
pub mod constants;
|
|
6
|
+
/// Utility functions for working with protobuf types.
|
|
6
7
|
pub mod utilities;
|
|
7
8
|
|
|
8
9
|
#[cfg(feature = "test-utilities")]
|
|
10
|
+
/// Pre-built test histories for common workflow patterns.
|
|
9
11
|
pub mod canned_histories;
|
|
10
12
|
#[cfg(feature = "history_builders")]
|
|
11
13
|
mod history_builder;
|
|
@@ -15,6 +17,8 @@ mod task_token;
|
|
|
15
17
|
#[cfg(feature = "test-utilities")]
|
|
16
18
|
pub mod test_utils;
|
|
17
19
|
|
|
20
|
+
use std::time::Duration;
|
|
21
|
+
|
|
18
22
|
#[cfg(feature = "history_builders")]
|
|
19
23
|
pub use history_builder::{
|
|
20
24
|
DEFAULT_ACTIVITY_TYPE, DEFAULT_WORKFLOW_TYPE, TestHistoryBuilder, default_act_sched,
|
|
@@ -24,12 +28,23 @@ pub use history_builder::{
|
|
|
24
28
|
pub use history_info::HistoryInfo;
|
|
25
29
|
pub use task_token::TaskToken;
|
|
26
30
|
|
|
31
|
+
/// Payload metadata key that identifies the encoding format.
|
|
27
32
|
pub static ENCODING_PAYLOAD_KEY: &str = "encoding";
|
|
33
|
+
/// The metadata value for JSON-encoded payloads.
|
|
28
34
|
pub static JSON_ENCODING_VAL: &str = "json/plain";
|
|
35
|
+
/// The details key used in patched marker payloads.
|
|
29
36
|
pub static PATCHED_MARKER_DETAILS_KEY: &str = "patch-data";
|
|
30
37
|
/// The search attribute key used when registering change versions
|
|
31
38
|
pub static VERSION_SEARCH_ATTR_KEY: &str = "TemporalChangeVersion";
|
|
32
39
|
|
|
40
|
+
macro_rules! include_proto_with_serde {
|
|
41
|
+
($pkg:tt) => {
|
|
42
|
+
tonic::include_proto!($pkg);
|
|
43
|
+
|
|
44
|
+
include!(concat!(env!("OUT_DIR"), concat!("/", $pkg, ".serde.rs")));
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
#[allow(
|
|
34
49
|
clippy::large_enum_variant,
|
|
35
50
|
clippy::derive_partial_eq_without_eq,
|
|
@@ -70,7 +85,7 @@ pub mod coresdk {
|
|
|
70
85
|
|
|
71
86
|
#[allow(clippy::module_inception)]
|
|
72
87
|
pub mod activity_task {
|
|
73
|
-
use crate::protos::{coresdk::ActivityTaskCompletion, task_token::
|
|
88
|
+
use crate::protos::{coresdk::ActivityTaskCompletion, task_token::format_task_token};
|
|
74
89
|
use std::fmt::{Display, Formatter};
|
|
75
90
|
tonic::include_proto!("coresdk.activity_task");
|
|
76
91
|
|
|
@@ -119,7 +134,7 @@ pub mod coresdk {
|
|
|
119
134
|
write!(
|
|
120
135
|
f,
|
|
121
136
|
"ActivityTaskCompletion(token: {}",
|
|
122
|
-
|
|
137
|
+
format_task_token(&self.task_token),
|
|
123
138
|
)?;
|
|
124
139
|
if let Some(r) = self.result.as_ref().and_then(|r| r.status.as_ref()) {
|
|
125
140
|
write!(f, ", {r}")?;
|
|
@@ -270,9 +285,7 @@ pub mod coresdk {
|
|
|
270
285
|
match self.status {
|
|
271
286
|
Some(activity_resolution::Status::Failed(Failure {
|
|
272
287
|
failure: Some(ref f),
|
|
273
|
-
})) => f
|
|
274
|
-
.is_timeout()
|
|
275
|
-
.or_else(|| f.cause.as_ref().and_then(|c| c.is_timeout())),
|
|
288
|
+
})) => f.is_timeout(),
|
|
276
289
|
_ => None,
|
|
277
290
|
}
|
|
278
291
|
}
|
|
@@ -521,6 +534,7 @@ pub mod coresdk {
|
|
|
521
534
|
deployment_version_for_current_task: None,
|
|
522
535
|
last_sdk_version: String::new(),
|
|
523
536
|
suggest_continue_as_new_reasons: vec![],
|
|
537
|
+
target_worker_deployment_version_changed: false,
|
|
524
538
|
}
|
|
525
539
|
}
|
|
526
540
|
|
|
@@ -821,16 +835,35 @@ pub mod coresdk {
|
|
|
821
835
|
nexus_task_completion::Status::Completed(c) => {
|
|
822
836
|
write!(f, "{c}")
|
|
823
837
|
}
|
|
824
|
-
nexus_task_completion::Status::Error(e) => {
|
|
825
|
-
write!(f, "{e}")
|
|
826
|
-
}
|
|
827
838
|
nexus_task_completion::Status::AckCancel(_) => {
|
|
828
839
|
write!(f, "AckCancel")
|
|
829
840
|
}
|
|
841
|
+
#[allow(deprecated)]
|
|
842
|
+
nexus_task_completion::Status::Error(error) => {
|
|
843
|
+
write!(f, "Error({error:?})")
|
|
844
|
+
}
|
|
845
|
+
nexus_task_completion::Status::Failure(failure) => {
|
|
846
|
+
write!(f, "{failure}")
|
|
847
|
+
}
|
|
830
848
|
}?;
|
|
831
849
|
write!(f, ")")
|
|
832
850
|
}
|
|
833
851
|
}
|
|
852
|
+
|
|
853
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
854
|
+
pub enum NexusOperationErrorState {
|
|
855
|
+
Failed,
|
|
856
|
+
Canceled,
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
impl Display for NexusOperationErrorState {
|
|
860
|
+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
861
|
+
match self {
|
|
862
|
+
Self::Failed => write!(f, "failed"),
|
|
863
|
+
Self::Canceled => write!(f, "canceled"),
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
834
867
|
}
|
|
835
868
|
|
|
836
869
|
pub mod workflow_commands {
|
|
@@ -942,11 +975,12 @@ pub mod coresdk {
|
|
|
942
975
|
|
|
943
976
|
impl Display for UpsertWorkflowSearchAttributes {
|
|
944
977
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
978
|
+
let keys: Vec<_> = self
|
|
979
|
+
.search_attributes
|
|
980
|
+
.as_ref()
|
|
981
|
+
.map(|sa| sa.indexed_fields.keys().collect())
|
|
982
|
+
.unwrap_or_default();
|
|
983
|
+
write!(f, "UpsertWorkflowSearchAttributes({:?})", keys)
|
|
950
984
|
}
|
|
951
985
|
}
|
|
952
986
|
|
|
@@ -1314,7 +1348,13 @@ pub mod coresdk {
|
|
|
1314
1348
|
pub fn is_timeout(&self) -> Option<crate::protos::temporal::api::enums::v1::TimeoutType> {
|
|
1315
1349
|
match &self.failure_info {
|
|
1316
1350
|
Some(FailureInfo::TimeoutFailureInfo(ti)) => Some(ti.timeout_type()),
|
|
1317
|
-
_ =>
|
|
1351
|
+
_ => {
|
|
1352
|
+
if let Some(c) = &self.cause {
|
|
1353
|
+
c.is_timeout()
|
|
1354
|
+
} else {
|
|
1355
|
+
None
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1318
1358
|
}
|
|
1319
1359
|
}
|
|
1320
1360
|
|
|
@@ -1780,7 +1820,7 @@ pub mod temporal {
|
|
|
1780
1820
|
fn from(s: workflow_commands::UpsertWorkflowSearchAttributes) -> Self {
|
|
1781
1821
|
Self::UpsertWorkflowSearchAttributesCommandAttributes(
|
|
1782
1822
|
UpsertWorkflowSearchAttributesCommandAttributes {
|
|
1783
|
-
search_attributes:
|
|
1823
|
+
search_attributes: s.search_attributes,
|
|
1784
1824
|
},
|
|
1785
1825
|
)
|
|
1786
1826
|
}
|
|
@@ -1845,7 +1885,7 @@ pub mod temporal {
|
|
|
1845
1885
|
task_queue: Some(s.task_queue.into()),
|
|
1846
1886
|
header: Some(s.headers.into()),
|
|
1847
1887
|
memo: Some(s.memo.into()),
|
|
1848
|
-
search_attributes:
|
|
1888
|
+
search_attributes: s.search_attributes,
|
|
1849
1889
|
input: s.input.into_payloads(),
|
|
1850
1890
|
workflow_id_reuse_policy: s.workflow_id_reuse_policy,
|
|
1851
1891
|
workflow_execution_timeout: s.workflow_execution_timeout,
|
|
@@ -1903,11 +1943,7 @@ pub mod temporal {
|
|
|
1903
1943
|
Some(c.headers.into())
|
|
1904
1944
|
},
|
|
1905
1945
|
retry_policy: c.retry_policy,
|
|
1906
|
-
search_attributes:
|
|
1907
|
-
None
|
|
1908
|
-
} else {
|
|
1909
|
-
Some(c.search_attributes.into())
|
|
1910
|
-
},
|
|
1946
|
+
search_attributes: c.search_attributes,
|
|
1911
1947
|
inherit_build_id,
|
|
1912
1948
|
initial_versioning_behavior: c.initial_versioning_behavior,
|
|
1913
1949
|
..Default::default()
|
|
@@ -2007,7 +2043,7 @@ pub mod temporal {
|
|
|
2007
2043
|
collections::HashMap,
|
|
2008
2044
|
fmt::{Display, Formatter},
|
|
2009
2045
|
};
|
|
2010
|
-
|
|
2046
|
+
include_proto_with_serde!("temporal.api.common.v1");
|
|
2011
2047
|
|
|
2012
2048
|
impl<T> From<T> for Payload
|
|
2013
2049
|
where
|
|
@@ -2140,12 +2176,17 @@ pub mod temporal {
|
|
|
2140
2176
|
}
|
|
2141
2177
|
pub mod enums {
|
|
2142
2178
|
pub mod v1 {
|
|
2143
|
-
|
|
2179
|
+
include_proto_with_serde!("temporal.api.enums.v1");
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
pub mod errordetails {
|
|
2183
|
+
pub mod v1 {
|
|
2184
|
+
tonic::include_proto!("temporal.api.errordetails.v1");
|
|
2144
2185
|
}
|
|
2145
2186
|
}
|
|
2146
2187
|
pub mod failure {
|
|
2147
2188
|
pub mod v1 {
|
|
2148
|
-
|
|
2189
|
+
include_proto_with_serde!("temporal.api.failure.v1");
|
|
2149
2190
|
}
|
|
2150
2191
|
}
|
|
2151
2192
|
pub mod filter {
|
|
@@ -2552,13 +2593,20 @@ pub mod temporal {
|
|
|
2552
2593
|
use crate::protos::{
|
|
2553
2594
|
camel_case_to_screaming_snake,
|
|
2554
2595
|
temporal::api::{
|
|
2555
|
-
common
|
|
2556
|
-
|
|
2596
|
+
common::{
|
|
2597
|
+
self,
|
|
2598
|
+
v1::link::{WorkflowEvent, workflow_event},
|
|
2599
|
+
},
|
|
2557
2600
|
enums::v1::EventType,
|
|
2601
|
+
failure,
|
|
2558
2602
|
},
|
|
2559
2603
|
};
|
|
2560
2604
|
use anyhow::{anyhow, bail};
|
|
2561
|
-
use
|
|
2605
|
+
use prost::Name;
|
|
2606
|
+
use std::{
|
|
2607
|
+
collections::HashMap,
|
|
2608
|
+
fmt::{Display, Formatter},
|
|
2609
|
+
};
|
|
2562
2610
|
use tonic::transport::Uri;
|
|
2563
2611
|
|
|
2564
2612
|
tonic::include_proto!("temporal.api.nexus.v1");
|
|
@@ -2595,6 +2643,11 @@ pub mod temporal {
|
|
|
2595
2643
|
}
|
|
2596
2644
|
}
|
|
2597
2645
|
|
|
2646
|
+
pub enum NexusTaskFailure {
|
|
2647
|
+
Legacy(HandlerError),
|
|
2648
|
+
Temporal(failure::v1::Failure),
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2598
2651
|
static SCHEME_PREFIX: &str = "temporal://";
|
|
2599
2652
|
|
|
2600
2653
|
/// Attempt to parse a nexus lint into a workflow event link
|
|
@@ -2676,6 +2729,30 @@ pub mod temporal {
|
|
|
2676
2729
|
})),
|
|
2677
2730
|
})
|
|
2678
2731
|
}
|
|
2732
|
+
|
|
2733
|
+
impl TryFrom<failure::v1::Failure> for Failure {
|
|
2734
|
+
type Error = serde_json::Error;
|
|
2735
|
+
|
|
2736
|
+
fn try_from(mut f: failure::v1::Failure) -> Result<Self, Self::Error> {
|
|
2737
|
+
// 1. Remove message from failure
|
|
2738
|
+
let message = std::mem::take(&mut f.message);
|
|
2739
|
+
|
|
2740
|
+
// 2. Serialize Failure as JSON
|
|
2741
|
+
let details = serde_json::to_vec(&f)?;
|
|
2742
|
+
|
|
2743
|
+
// 3. Package Temporal Failure as Nexus Failure
|
|
2744
|
+
Ok(Failure {
|
|
2745
|
+
message,
|
|
2746
|
+
stack_trace: f.stack_trace,
|
|
2747
|
+
metadata: HashMap::from([(
|
|
2748
|
+
"type".to_string(),
|
|
2749
|
+
failure::v1::Failure::full_name().into(),
|
|
2750
|
+
)]),
|
|
2751
|
+
details,
|
|
2752
|
+
cause: None,
|
|
2753
|
+
})
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2679
2756
|
}
|
|
2680
2757
|
}
|
|
2681
2758
|
pub mod workflowservice {
|
|
@@ -2791,6 +2868,18 @@ pub mod temporal {
|
|
|
2791
2868
|
}
|
|
2792
2869
|
}
|
|
2793
2870
|
|
|
2871
|
+
#[allow(
|
|
2872
|
+
clippy::all,
|
|
2873
|
+
missing_docs,
|
|
2874
|
+
rustdoc::broken_intra_doc_links,
|
|
2875
|
+
rustdoc::bare_urls
|
|
2876
|
+
)]
|
|
2877
|
+
pub mod google {
|
|
2878
|
+
pub mod rpc {
|
|
2879
|
+
tonic::include_proto!("google.rpc");
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2794
2883
|
#[allow(
|
|
2795
2884
|
clippy::all,
|
|
2796
2885
|
missing_docs,
|
|
@@ -2824,6 +2913,12 @@ pub fn camel_case_to_screaming_snake(val: &str) -> String {
|
|
|
2824
2913
|
out
|
|
2825
2914
|
}
|
|
2826
2915
|
|
|
2916
|
+
/// Convert a protobuf [`prost_types::Timestamp`] to a [`std::time::SystemTime`].
|
|
2917
|
+
pub fn proto_ts_to_system_time(ts: &prost_types::Timestamp) -> Option<std::time::SystemTime> {
|
|
2918
|
+
std::time::SystemTime::UNIX_EPOCH
|
|
2919
|
+
.checked_add(Duration::from_secs(ts.seconds as u64) + Duration::from_nanos(ts.nanos as u64))
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2827
2922
|
#[cfg(test)]
|
|
2828
2923
|
mod tests {
|
|
2829
2924
|
use crate::protos::temporal::api::failure::v1::Failure;
|
|
@@ -36,13 +36,13 @@ impl TaskToken {
|
|
|
36
36
|
|
|
37
37
|
impl Display for TaskToken {
|
|
38
38
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
39
|
-
f.write_str(&
|
|
39
|
+
f.write_str(&format_task_token(&self.0))
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
impl Debug for TaskToken {
|
|
44
44
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
45
|
-
f.write_str(&format!("TaskToken({})",
|
|
45
|
+
f.write_str(&format!("TaskToken({})", format_task_token(&self.0)))
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -52,6 +52,6 @@ impl Borrow<[u8]> for TaskToken {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
pub(crate) fn
|
|
55
|
+
pub(crate) fn format_task_token(tt: &[u8]) -> String {
|
|
56
56
|
BASE64_STANDARD.encode(tt)
|
|
57
57
|
}
|
|
@@ -2,6 +2,7 @@ use std::collections::HashMap;
|
|
|
2
2
|
|
|
3
3
|
use prost::{EncodeError, Message};
|
|
4
4
|
|
|
5
|
+
/// Extension trait for converting `Option<F>` to `Option<T>`, returning `None` on failure.
|
|
5
6
|
pub trait TryIntoOrNone<F, T> {
|
|
6
7
|
/// Turn an option of something into an option of another thing, trying to convert along the way
|
|
7
8
|
/// and returning `None` if that conversion fails
|
|
@@ -26,6 +27,16 @@ pub fn pack_any<T: Message>(type_url: String, msg: &T) -> Result<prost_types::An
|
|
|
26
27
|
Ok(prost_types::Any { type_url, value })
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/// Decode a specific protobuf message type from gRPC status details bytes.
|
|
31
|
+
///
|
|
32
|
+
/// The details bytes should be the serialized `google.rpc.Status` message from
|
|
33
|
+
/// `tonic::Status::details()`.
|
|
34
|
+
pub fn decode_status_detail<T: Message + Default>(details: &[u8]) -> Option<T> {
|
|
35
|
+
let status = super::google::rpc::Status::decode(details).ok()?;
|
|
36
|
+
let first_detail = status.details.first()?;
|
|
37
|
+
T::decode(first_detail.value.as_slice()).ok()
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
/// Given a header map, lowercase all the keys and return it as a new map.
|
|
30
41
|
/// Any keys that are duplicated after lowercasing will clobber each other in undefined ordering.
|
|
31
42
|
pub fn normalize_http_headers(headers: HashMap<String, String>) -> HashMap<String, String> {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
use crate::telemetry::{CoreLog, CoreLogConsumer};
|
|
1
2
|
use futures_channel::mpsc::{Receiver, Sender, channel};
|
|
2
3
|
use parking_lot::Mutex;
|
|
3
4
|
use ringbuf::{HeapRb, consumer::Consumer, producer::Producer, traits::Split};
|
|
4
5
|
use std::{collections::HashMap, fmt, sync::Arc, time::SystemTime};
|
|
5
|
-
use temporalio_common::telemetry::{CoreLog, CoreLogConsumer};
|
|
6
6
|
use tracing_subscriber::Layer;
|
|
7
7
|
|
|
8
8
|
#[derive(Debug)]
|
|
@@ -215,18 +215,15 @@ impl tracing::field::Visit for JsonVisitor<'_> {
|
|
|
215
215
|
|
|
216
216
|
#[cfg(test)]
|
|
217
217
|
mod tests {
|
|
218
|
-
use crate::{
|
|
219
|
-
|
|
220
|
-
telemetry_init,
|
|
218
|
+
use crate::telemetry::{
|
|
219
|
+
CoreLog, CoreLogConsumer, CoreLogStreamConsumer, CoreTelemetry, Logger, TelemetryOptions,
|
|
220
|
+
construct_filter_string, telemetry_init,
|
|
221
221
|
};
|
|
222
222
|
use futures_util::stream::StreamExt;
|
|
223
223
|
use std::{
|
|
224
224
|
fmt,
|
|
225
225
|
sync::{Arc, Mutex},
|
|
226
226
|
};
|
|
227
|
-
use temporalio_common::telemetry::{
|
|
228
|
-
CoreLog, CoreLogConsumer, CoreTelemetry, Logger, TelemetryOptions,
|
|
229
|
-
};
|
|
230
227
|
use tracing::Level;
|
|
231
228
|
|
|
232
229
|
#[instrument(fields(bros = "brohemian"))]
|
|
@@ -246,6 +243,7 @@ mod tests {
|
|
|
246
243
|
|
|
247
244
|
fn assert_logs(logs: Vec<CoreLog>) {
|
|
248
245
|
// Verify debug log was not forwarded
|
|
246
|
+
dbg!(&logs);
|
|
249
247
|
assert!(!logs.iter().any(|l| l.message == "debug"));
|
|
250
248
|
assert_eq!(logs.len(), 4);
|
|
251
249
|
// Ensure fields are attached to events properly
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//! Metrics related code only needed by core and core-based SDKs
|
|
2
|
+
|
|
3
|
+
use crate::telemetry::metrics::{MetricKeyValue, MetricParameters};
|
|
4
|
+
use std::{
|
|
5
|
+
any::Any,
|
|
6
|
+
fmt::Debug,
|
|
7
|
+
sync::{Arc, OnceLock},
|
|
8
|
+
time::Duration,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/// A reference to some attributes created lang side.
|
|
12
|
+
pub trait CustomMetricAttributes: Debug + Send + Sync {
|
|
13
|
+
/// Must be implemented to work around existing type system restrictions, see
|
|
14
|
+
/// [here](https://internals.rust-lang.org/t/downcast-not-from-any-but-from-any-trait/16736/12)
|
|
15
|
+
fn as_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// Events produced by the metrics buffering layer for deferred processing by lang.
|
|
19
|
+
#[derive(Debug, Clone)]
|
|
20
|
+
pub enum MetricEvent<I: BufferInstrumentRef> {
|
|
21
|
+
/// Request to create a new metric instrument.
|
|
22
|
+
Create {
|
|
23
|
+
/// Parameters (name, description, unit) for the new instrument.
|
|
24
|
+
params: MetricParameters,
|
|
25
|
+
/// Once you receive this event, call `set` on this with the initialized instrument
|
|
26
|
+
/// reference
|
|
27
|
+
populate_into: LazyBufferInstrument<I>,
|
|
28
|
+
/// The kind of metric instrument to create.
|
|
29
|
+
kind: MetricKind,
|
|
30
|
+
},
|
|
31
|
+
/// Request to create a new set of metric attributes.
|
|
32
|
+
CreateAttributes {
|
|
33
|
+
/// Once you receive this event, call `set` on this with the initialized attributes
|
|
34
|
+
populate_into: BufferAttributes,
|
|
35
|
+
/// If not `None`, use these already-initialized attributes as the base (extended with
|
|
36
|
+
/// `attributes`) for the ones you are about to initialize.
|
|
37
|
+
append_from: Option<BufferAttributes>,
|
|
38
|
+
/// The key-value pairs for the new attribute set.
|
|
39
|
+
attributes: Vec<MetricKeyValue>,
|
|
40
|
+
},
|
|
41
|
+
/// A metric recording to apply to an already-created instrument.
|
|
42
|
+
Update {
|
|
43
|
+
/// The instrument to record against.
|
|
44
|
+
instrument: LazyBufferInstrument<I>,
|
|
45
|
+
/// The attributes to associate with this recording.
|
|
46
|
+
attributes: BufferAttributes,
|
|
47
|
+
/// The value to record.
|
|
48
|
+
update: MetricUpdateVal,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
/// The kind of metric instrument to create.
|
|
52
|
+
#[derive(Debug, Clone, Copy)]
|
|
53
|
+
pub enum MetricKind {
|
|
54
|
+
/// A monotonically increasing `u64` counter.
|
|
55
|
+
Counter,
|
|
56
|
+
/// A `u64` gauge that can go up or down.
|
|
57
|
+
Gauge,
|
|
58
|
+
/// An `f64` gauge that can go up or down.
|
|
59
|
+
GaugeF64,
|
|
60
|
+
/// A `u64` histogram for recording distributions.
|
|
61
|
+
Histogram,
|
|
62
|
+
/// An `f64` histogram for recording distributions.
|
|
63
|
+
HistogramF64,
|
|
64
|
+
/// A histogram that records [`Duration`] values.
|
|
65
|
+
HistogramDuration,
|
|
66
|
+
}
|
|
67
|
+
/// The value to record when updating a metric instrument.
|
|
68
|
+
#[derive(Debug, Clone, Copy)]
|
|
69
|
+
pub enum MetricUpdateVal {
|
|
70
|
+
/// A `u64` delta increment (for counters/histograms).
|
|
71
|
+
Delta(u64),
|
|
72
|
+
/// An `f64` delta increment (for f64 histograms).
|
|
73
|
+
DeltaF64(f64),
|
|
74
|
+
/// An absolute `u64` value (for gauges).
|
|
75
|
+
Value(u64),
|
|
76
|
+
/// An absolute `f64` value (for f64 gauges).
|
|
77
|
+
ValueF64(f64),
|
|
78
|
+
/// A duration observation (for duration histograms).
|
|
79
|
+
Duration(Duration),
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Collects buffered metric events for later replay into a real metrics backend.
|
|
83
|
+
pub trait MetricCallBufferer<I: BufferInstrumentRef>: Send + Sync {
|
|
84
|
+
/// Drain and return all buffered metric events.
|
|
85
|
+
fn retrieve(&self) -> Vec<MetricEvent<I>>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// A lazy reference to some metrics buffer attributes
|
|
89
|
+
pub type BufferAttributes = LazyRef<Arc<dyn CustomMetricAttributes + 'static>>;
|
|
90
|
+
|
|
91
|
+
/// Types lang uses to contain references to its lang-side defined instrument references must
|
|
92
|
+
/// implement this marker trait
|
|
93
|
+
pub trait BufferInstrumentRef {}
|
|
94
|
+
/// A lazy reference to a metrics buffer instrument
|
|
95
|
+
pub type LazyBufferInstrument<T> = LazyRef<Arc<T>>;
|
|
96
|
+
|
|
97
|
+
/// A shared, lazily-initialized reference. Created as an empty "hole" and filled later via [`set`](Self::set).
|
|
98
|
+
#[derive(Debug, Clone)]
|
|
99
|
+
pub struct LazyRef<T> {
|
|
100
|
+
to_be_initted: Arc<OnceLock<T>>,
|
|
101
|
+
}
|
|
102
|
+
impl<T> LazyRef<T> {
|
|
103
|
+
/// Create an uninitialized hole that must be filled with [`set`](Self::set) before use.
|
|
104
|
+
pub fn hole() -> Self {
|
|
105
|
+
Self {
|
|
106
|
+
to_be_initted: Arc::new(OnceLock::new()),
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// Get the reference you previously initialized
|
|
111
|
+
///
|
|
112
|
+
/// # Panics
|
|
113
|
+
/// If `set` has not already been called. You must set the reference before using it.
|
|
114
|
+
pub fn get(&self) -> &T {
|
|
115
|
+
self.to_be_initted
|
|
116
|
+
.get()
|
|
117
|
+
.expect("You must initialize the reference before using it")
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// Assigns a value to fill this reference.
|
|
121
|
+
/// Returns according to semantics of [OnceLock].
|
|
122
|
+
pub fn set(&self, val: T) -> Result<(), T> {
|
|
123
|
+
self.to_be_initted.set(val)
|
|
124
|
+
}
|
|
125
|
+
}
|