@temporalio/core-bridge 1.11.7 → 1.11.8
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 +504 -341
- package/package.json +3 -3
- 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/.cargo/config.toml +5 -0
- package/sdk-core/.github/workflows/per-pr.yml +59 -5
- package/sdk-core/Cargo.toml +3 -2
- package/sdk-core/client/Cargo.toml +3 -3
- package/sdk-core/client/src/lib.rs +154 -161
- package/sdk-core/client/src/metrics.rs +15 -8
- package/sdk-core/client/src/proxy.rs +1 -1
- package/sdk-core/client/src/raw.rs +176 -33
- package/sdk-core/client/src/retry.rs +102 -465
- package/sdk-core/client/src/worker_registry/mod.rs +2 -2
- package/sdk-core/client/src/workflow_handle/mod.rs +19 -1
- package/sdk-core/core/Cargo.toml +12 -14
- package/sdk-core/core/benches/workflow_replay.rs +1 -1
- package/sdk-core/core/src/abstractions.rs +2 -2
- package/sdk-core/core/src/core_tests/activity_tasks.rs +99 -46
- package/sdk-core/core/src/core_tests/child_workflows.rs +68 -9
- package/sdk-core/core/src/core_tests/determinism.rs +2 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +20 -33
- package/sdk-core/core/src/core_tests/mod.rs +7 -8
- package/sdk-core/core/src/core_tests/queries.rs +79 -79
- package/sdk-core/core/src/core_tests/replay_flag.rs +5 -5
- package/sdk-core/core/src/core_tests/updates.rs +6 -6
- package/sdk-core/core/src/core_tests/workers.rs +19 -22
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +3 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +154 -106
- package/sdk-core/core/src/ephemeral_server/mod.rs +66 -10
- package/sdk-core/core/src/internal_flags.rs +103 -12
- package/sdk-core/core/src/lib.rs +21 -13
- package/sdk-core/core/src/pollers/mod.rs +200 -6
- package/sdk-core/core/src/pollers/poll_buffer.rs +32 -8
- package/sdk-core/core/src/protosext/mod.rs +7 -7
- package/sdk-core/core/src/protosext/protocol_messages.rs +2 -2
- package/sdk-core/core/src/replay/mod.rs +8 -9
- package/sdk-core/core/src/retry_logic.rs +8 -6
- package/sdk-core/core/src/telemetry/log_export.rs +4 -4
- package/sdk-core/core/src/telemetry/metrics.rs +111 -25
- package/sdk-core/core/src/telemetry/mod.rs +11 -4
- package/sdk-core/core/src/telemetry/otel.rs +108 -144
- package/sdk-core/core/src/telemetry/prometheus_server.rs +1 -4
- package/sdk-core/core/src/test_help/mod.rs +27 -21
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -5
- package/sdk-core/core/src/worker/activities/local_activities.rs +9 -9
- package/sdk-core/core/src/worker/activities.rs +34 -46
- package/sdk-core/core/src/worker/client/mocks.rs +24 -2
- package/sdk-core/core/src/worker/client.rs +169 -33
- package/sdk-core/core/src/worker/mod.rs +132 -56
- package/sdk-core/core/src/worker/nexus.rs +410 -0
- package/sdk-core/core/src/worker/tuner/resource_based.rs +27 -5
- package/sdk-core/core/src/worker/tuner.rs +29 -2
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +8 -3
- package/sdk-core/core/src/worker/workflow/history_update.rs +5 -8
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +83 -87
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +38 -38
- package/sdk-core/core/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +117 -0
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +8 -18
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +114 -108
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +16 -31
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -14
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +8 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +34 -75
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +26 -48
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +10 -17
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +543 -0
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +22 -31
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +53 -51
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +40 -45
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +8 -10
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +24 -30
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +182 -116
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +4 -8
- package/sdk-core/core/src/worker/workflow/managed_run.rs +75 -45
- package/sdk-core/core/src/worker/workflow/mod.rs +104 -55
- package/sdk-core/core/src/worker/workflow/run_cache.rs +23 -4
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +4 -4
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +32 -13
- package/sdk-core/core-api/Cargo.toml +2 -3
- package/sdk-core/core-api/src/errors.rs +22 -20
- package/sdk-core/core-api/src/lib.rs +24 -5
- package/sdk-core/core-api/src/telemetry/metrics.rs +27 -1
- package/sdk-core/core-api/src/telemetry.rs +37 -3
- package/sdk-core/core-api/src/worker.rs +36 -3
- package/sdk-core/docker/docker-compose-ci.yaml +25 -0
- package/sdk-core/etc/otel-collector-ci.yaml +36 -0
- package/sdk-core/etc/otel-collector-config.yaml +3 -3
- package/sdk-core/etc/prometheus.yaml +1 -1
- package/sdk-core/fsm/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +3 -4
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
- package/sdk-core/sdk/Cargo.toml +1 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -1
- package/sdk-core/sdk/src/lib.rs +126 -54
- package/sdk-core/sdk/src/workflow_context/options.rs +184 -74
- package/sdk-core/sdk/src/workflow_context.rs +193 -79
- package/sdk-core/sdk/src/workflow_future.rs +151 -131
- package/sdk-core/sdk-core-protos/Cargo.toml +3 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +46 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +254 -5
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +108 -2
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +94 -15
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +102 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +84 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +25 -10
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +14 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +25 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +41 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +59 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +135 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/push-to-buf.yml +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +13 -21
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3386 -1047
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +3529 -1144
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +252 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +96 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/nexus.proto +42 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +43 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +13 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +14 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +70 -12
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +12 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/query/v1/message.proto +9 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +206 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +482 -97
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +230 -43
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/nexus/nexus.proto +71 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +55 -9
- package/sdk-core/sdk-core-protos/src/history_builder.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_info.rs +5 -6
- package/sdk-core/sdk-core-protos/src/lib.rs +414 -34
- package/sdk-core/sdk-core-protos/src/task_token.rs +1 -1
- package/sdk-core/test-utils/Cargo.toml +3 -11
- package/sdk-core/test-utils/src/canned_histories.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +159 -85
- package/sdk-core/tests/fuzzy_workflow.rs +3 -3
- package/sdk-core/tests/heavy_tests.rs +3 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +171 -20
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +45 -39
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +7 -6
- package/sdk-core/tests/integ_tests/metrics_tests.rs +492 -35
- package/sdk-core/tests/integ_tests/polling_tests.rs +7 -5
- package/sdk-core/tests/integ_tests/queries_tests.rs +14 -17
- package/sdk-core/tests/integ_tests/update_tests.rs +47 -44
- package/sdk-core/tests/integ_tests/visibility_tests.rs +4 -3
- package/sdk-core/tests/integ_tests/worker_tests.rs +5 -5
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +15 -13
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +28 -14
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +57 -4
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +24 -18
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +506 -0
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/priority.rs +104 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +34 -31
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +152 -116
- package/sdk-core/tests/main.rs +36 -6
- package/sdk-core/tests/runner.rs +30 -9
- package/src/conversions/slot_supplier_bridge.rs +4 -0
- package/src/conversions.rs +1 -0
- package/src/worker.rs +5 -7
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -78
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
receivers:
|
|
2
|
+
otlp:
|
|
3
|
+
protocols:
|
|
4
|
+
grpc:
|
|
5
|
+
endpoint: 0.0.0.0:4317
|
|
6
|
+
http:
|
|
7
|
+
endpoint: 0.0.0.0:4318
|
|
8
|
+
|
|
9
|
+
exporters:
|
|
10
|
+
prometheus:
|
|
11
|
+
endpoint: '0.0.0.0:8889'
|
|
12
|
+
namespace: temporal_sdk
|
|
13
|
+
|
|
14
|
+
debug:
|
|
15
|
+
|
|
16
|
+
processors:
|
|
17
|
+
batch:
|
|
18
|
+
|
|
19
|
+
extensions:
|
|
20
|
+
health_check:
|
|
21
|
+
pprof:
|
|
22
|
+
endpoint: :1888
|
|
23
|
+
zpages:
|
|
24
|
+
endpoint: :55679
|
|
25
|
+
|
|
26
|
+
service:
|
|
27
|
+
extensions: [ pprof, zpages, health_check ]
|
|
28
|
+
pipelines:
|
|
29
|
+
traces:
|
|
30
|
+
receivers: [ otlp ]
|
|
31
|
+
processors: [ batch ]
|
|
32
|
+
exporters: [ debug, ]
|
|
33
|
+
metrics:
|
|
34
|
+
receivers: [ otlp ]
|
|
35
|
+
processors: [ batch ]
|
|
36
|
+
exporters: [ debug, prometheus ]
|
|
@@ -11,7 +11,7 @@ exporters:
|
|
|
11
11
|
endpoint: '0.0.0.0:8889'
|
|
12
12
|
namespace: temporal_sdk
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
debug:
|
|
15
15
|
|
|
16
16
|
otlp/jaeger:
|
|
17
17
|
endpoint: jaeger:14250
|
|
@@ -32,8 +32,8 @@ service:
|
|
|
32
32
|
traces:
|
|
33
33
|
receivers: [ otlp ]
|
|
34
34
|
processors: [ batch ]
|
|
35
|
-
exporters: [
|
|
35
|
+
exporters: [ debug, otlp/jaeger ]
|
|
36
36
|
metrics:
|
|
37
37
|
receivers: [ otlp ]
|
|
38
38
|
processors: [ batch ]
|
|
39
|
-
exporters: [
|
|
39
|
+
exporters: [ debug, prometheus ]
|
package/sdk-core/fsm/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "rustfsm"
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
authors = ["Spencer Judge <spencer@temporal.io>"]
|
|
5
|
-
edition = "
|
|
5
|
+
edition = "2024"
|
|
6
6
|
license-file = "LICENSE.txt"
|
|
7
7
|
description = "Define state machines that can accept events and produce commands"
|
|
8
8
|
homepage = "https://temporal.io/"
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
use proc_macro::TokenStream;
|
|
2
2
|
use quote::{quote, quote_spanned};
|
|
3
|
-
use std::collections::{
|
|
3
|
+
use std::collections::{HashMap, HashSet, hash_map::Entry};
|
|
4
4
|
use syn::{
|
|
5
|
-
parenthesized,
|
|
5
|
+
Error, Fields, Ident, Token, Type, Variant, Visibility, parenthesized,
|
|
6
6
|
parse::{Parse, ParseStream, Result},
|
|
7
7
|
parse_macro_input,
|
|
8
8
|
spanned::Spanned,
|
|
9
|
-
Error, Fields, Ident, Token, Type, Variant, Visibility,
|
|
10
9
|
};
|
|
11
10
|
|
|
12
11
|
/// Parses a DSL for defining finite state machines, and produces code implementing the
|
|
@@ -287,7 +286,7 @@ impl Parse for Transition {
|
|
|
287
286
|
return Err(Error::new(
|
|
288
287
|
event.span(),
|
|
289
288
|
"Struct variants are not supported for events",
|
|
290
|
-
))
|
|
289
|
+
));
|
|
291
290
|
}
|
|
292
291
|
Fields::Unnamed(uf) => {
|
|
293
292
|
if uf.unnamed.len() != 1 {
|
package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr
CHANGED
|
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `One: From<Two>` is not satisfied
|
|
|
2
2
|
--> tests/trybuild/no_handle_conversions_require_into_fail.rs:11:5
|
|
3
3
|
|
|
|
4
4
|
11 | Two --(B)--> One;
|
|
5
|
-
| ^^^ the trait `From<Two>` is not implemented for `One
|
|
5
|
+
| ^^^ the trait `From<Two>` is not implemented for `One`
|
|
6
6
|
|
|
|
7
7
|
= note: required for `Two` to implement `Into<One>`
|
|
8
8
|
note: required by a bound in `TransitionResult::<Sm, Ds>::from`
|
package/sdk-core/sdk/Cargo.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "temporal-sdk"
|
|
3
3
|
version = "0.1.0-alpha.1"
|
|
4
|
-
edition = "
|
|
4
|
+
edition = "2024"
|
|
5
5
|
authors = ["Spencer Judge <spencer@temporal.io>"]
|
|
6
6
|
license-file = { workspace = true }
|
|
7
7
|
description = "Temporal Rust SDK"
|
|
@@ -12,7 +12,6 @@ categories = ["development-tools"]
|
|
|
12
12
|
|
|
13
13
|
[dependencies]
|
|
14
14
|
async-trait = "0.1"
|
|
15
|
-
thiserror = "1.0"
|
|
16
15
|
anyhow = "1.0"
|
|
17
16
|
derive_more = { workspace = true }
|
|
18
17
|
futures-util = { version = "0.3", default-features = false }
|
|
@@ -8,7 +8,7 @@ use std::{
|
|
|
8
8
|
};
|
|
9
9
|
use temporal_sdk_core_api::Worker;
|
|
10
10
|
use temporal_sdk_core_protos::{
|
|
11
|
-
coresdk::{
|
|
11
|
+
coresdk::{ActivityHeartbeat, activity_task},
|
|
12
12
|
temporal::api::common::v1::{Payload, RetryPolicy, WorkflowExecution},
|
|
13
13
|
utilities::TryIntoOrNone,
|
|
14
14
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
use crate::Worker;
|
|
4
4
|
use anyhow::bail;
|
|
5
5
|
use temporal_sdk_core_protos::coresdk::{
|
|
6
|
-
workflow_activation::{remove_from_cache::EvictionReason
|
|
6
|
+
workflow_activation::{WorkflowActivation, remove_from_cache::EvictionReason},
|
|
7
7
|
workflow_completion::WorkflowActivationCompletion,
|
|
8
8
|
};
|
|
9
9
|
|
package/sdk-core/sdk/src/lib.rs
CHANGED
|
@@ -53,17 +53,20 @@ mod workflow_future;
|
|
|
53
53
|
|
|
54
54
|
pub use activity_context::ActContext;
|
|
55
55
|
pub use temporal_client::Namespace;
|
|
56
|
-
use tracing::{
|
|
56
|
+
use tracing::{Instrument, Span, field};
|
|
57
57
|
pub use workflow_context::{
|
|
58
58
|
ActivityOptions, CancellableFuture, ChildWorkflow, ChildWorkflowOptions, LocalActivityOptions,
|
|
59
|
-
PendingChildWorkflow, Signal, SignalData, SignalWorkflowOptions,
|
|
60
|
-
WfContext,
|
|
59
|
+
NexusOperationOptions, PendingChildWorkflow, Signal, SignalData, SignalWorkflowOptions,
|
|
60
|
+
StartedChildWorkflow, TimerOptions, WfContext,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
use crate::{
|
|
64
|
-
|
|
63
|
+
use crate::{
|
|
64
|
+
interceptors::WorkerInterceptor,
|
|
65
|
+
workflow_context::{ChildWfCommon, NexusUnblockData, StartedNexusOperation},
|
|
66
|
+
};
|
|
67
|
+
use anyhow::{Context, anyhow, bail};
|
|
65
68
|
use app_data::AppData;
|
|
66
|
-
use futures_util::{
|
|
69
|
+
use futures_util::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::BoxFuture};
|
|
67
70
|
use serde::Serialize;
|
|
68
71
|
use std::{
|
|
69
72
|
any::{Any, TypeId},
|
|
@@ -77,34 +80,33 @@ use std::{
|
|
|
77
80
|
};
|
|
78
81
|
use temporal_client::ClientOptionsBuilder;
|
|
79
82
|
use temporal_sdk_core::Url;
|
|
80
|
-
use temporal_sdk_core_api::{
|
|
81
|
-
errors::{PollActivityError, PollWfError},
|
|
82
|
-
Worker as CoreWorker,
|
|
83
|
-
};
|
|
83
|
+
use temporal_sdk_core_api::{Worker as CoreWorker, errors::PollError};
|
|
84
84
|
use temporal_sdk_core_protos::{
|
|
85
|
+
TaskToken,
|
|
85
86
|
coresdk::{
|
|
87
|
+
ActivityTaskCompletion, AsJsonPayloadExt, FromJsonPayloadExt,
|
|
86
88
|
activity_result::{ActivityExecutionResult, ActivityResolution},
|
|
87
|
-
activity_task::{
|
|
89
|
+
activity_task::{ActivityTask, activity_task},
|
|
88
90
|
child_workflow::ChildWorkflowResult,
|
|
89
91
|
common::NamespacedWorkflowExecution,
|
|
92
|
+
nexus::NexusOperationResult,
|
|
90
93
|
workflow_activation::{
|
|
94
|
+
WorkflowActivation,
|
|
91
95
|
resolve_child_workflow_execution_start::Status as ChildWorkflowStartStatus,
|
|
92
|
-
workflow_activation_job::Variant,
|
|
96
|
+
resolve_nexus_operation_start, workflow_activation_job::Variant,
|
|
93
97
|
},
|
|
94
|
-
workflow_commands::{
|
|
98
|
+
workflow_commands::{ContinueAsNewWorkflowExecution, WorkflowCommand, workflow_command},
|
|
95
99
|
workflow_completion::WorkflowActivationCompletion,
|
|
96
|
-
ActivityTaskCompletion, AsJsonPayloadExt, FromJsonPayloadExt,
|
|
97
100
|
},
|
|
98
101
|
temporal::api::{
|
|
99
102
|
common::v1::Payload,
|
|
100
103
|
enums::v1::WorkflowTaskFailedCause,
|
|
101
|
-
failure::v1::{
|
|
104
|
+
failure::v1::{Failure, failure},
|
|
102
105
|
},
|
|
103
|
-
TaskToken,
|
|
104
106
|
};
|
|
105
107
|
use tokio::{
|
|
106
108
|
sync::{
|
|
107
|
-
mpsc::{
|
|
109
|
+
mpsc::{UnboundedSender, unbounded_channel},
|
|
108
110
|
oneshot,
|
|
109
111
|
},
|
|
110
112
|
task::JoinError,
|
|
@@ -191,7 +193,7 @@ impl Worker {
|
|
|
191
193
|
|
|
192
194
|
/// Return a handle that can be used to initiate shutdown.
|
|
193
195
|
/// TODO: Doc better after shutdown changes
|
|
194
|
-
pub fn shutdown_handle(&self) -> impl Fn() {
|
|
196
|
+
pub fn shutdown_handle(&self) -> impl Fn() + use<> {
|
|
195
197
|
let w = self.common.worker.clone();
|
|
196
198
|
move || w.initiate_shutdown()
|
|
197
199
|
}
|
|
@@ -280,7 +282,7 @@ impl Worker {
|
|
|
280
282
|
async {
|
|
281
283
|
loop {
|
|
282
284
|
let activation = match common.worker.poll_workflow_activation().await {
|
|
283
|
-
Err(
|
|
285
|
+
Err(PollError::ShutDown) => {
|
|
284
286
|
break;
|
|
285
287
|
}
|
|
286
288
|
o => o?,
|
|
@@ -315,7 +317,7 @@ impl Worker {
|
|
|
315
317
|
if !act_half.activity_fns.is_empty() {
|
|
316
318
|
loop {
|
|
317
319
|
let activity = common.worker.poll_activity_task().await;
|
|
318
|
-
if matches!(activity, Err(
|
|
320
|
+
if matches!(activity, Err(PollError::ShutDown)) {
|
|
319
321
|
break;
|
|
320
322
|
}
|
|
321
323
|
act_half.activity_task_handler(
|
|
@@ -381,15 +383,18 @@ impl Worker {
|
|
|
381
383
|
}
|
|
382
384
|
|
|
383
385
|
impl WorkflowHalf {
|
|
386
|
+
#[allow(clippy::type_complexity)]
|
|
384
387
|
fn workflow_activation_handler(
|
|
385
388
|
&self,
|
|
386
389
|
common: &CommonWorker,
|
|
387
390
|
shutdown_token: CancellationToken,
|
|
388
|
-
activation: WorkflowActivation,
|
|
391
|
+
mut activation: WorkflowActivation,
|
|
389
392
|
completions_tx: &UnboundedSender<WorkflowActivationCompletion>,
|
|
390
393
|
) -> Result<
|
|
391
394
|
Option<
|
|
392
|
-
WorkflowFutureHandle<
|
|
395
|
+
WorkflowFutureHandle<
|
|
396
|
+
impl Future<Output = Result<WorkflowResult<Payload>, JoinError>> + use<>,
|
|
397
|
+
>,
|
|
393
398
|
>,
|
|
394
399
|
anyhow::Error,
|
|
395
400
|
> {
|
|
@@ -398,8 +403,8 @@ impl WorkflowHalf {
|
|
|
398
403
|
|
|
399
404
|
// If the activation is to init a workflow, create a new workflow driver for it,
|
|
400
405
|
// using the function associated with that workflow id
|
|
401
|
-
if let Some(sw) = activation.jobs.
|
|
402
|
-
Some(Variant::InitializeWorkflow(ref sw)) => Some(sw),
|
|
406
|
+
if let Some(sw) = activation.jobs.iter_mut().find_map(|j| match j.variant {
|
|
407
|
+
Some(Variant::InitializeWorkflow(ref mut sw)) => Some(sw),
|
|
403
408
|
_ => None,
|
|
404
409
|
}) {
|
|
405
410
|
let workflow_type = &sw.workflow_type;
|
|
@@ -420,9 +425,7 @@ impl WorkflowHalf {
|
|
|
420
425
|
let (wff, activations) = wf_function.start_workflow(
|
|
421
426
|
common.worker.get_config().namespace.clone(),
|
|
422
427
|
common.task_queue.clone(),
|
|
423
|
-
|
|
424
|
-
// NOTE: Don't clone args if this gets ported to be a non-test rust worker
|
|
425
|
-
sw.arguments.clone(),
|
|
428
|
+
std::mem::take(sw),
|
|
426
429
|
completions_tx.clone(),
|
|
427
430
|
);
|
|
428
431
|
let jh = tokio::spawn(async move {
|
|
@@ -454,11 +457,11 @@ impl WorkflowHalf {
|
|
|
454
457
|
.send(activation)
|
|
455
458
|
.expect("Workflow should exist if we're sending it an activation");
|
|
456
459
|
} else {
|
|
457
|
-
// When we failed to start a workflow, we never inserted it into the cache.
|
|
458
|
-
//
|
|
459
|
-
// as a failure, which we need to complete.
|
|
460
|
-
//
|
|
461
|
-
//
|
|
460
|
+
// When we failed to start a workflow, we never inserted it into the cache. But core
|
|
461
|
+
// sends us a `RemoveFromCache` job when we mark the StartWorkflow workflow activation
|
|
462
|
+
// as a failure, which we need to complete. Other SDKs add the workflow to the cache
|
|
463
|
+
// even when the workflow type is unknown/not found. To circumvent this, we simply mark
|
|
464
|
+
// any RemoveFromCache job for workflows that are not in the cache as complete.
|
|
462
465
|
if activation.jobs.len() == 1
|
|
463
466
|
&& matches!(
|
|
464
467
|
activation.jobs.first().map(|j| &j.variant),
|
|
@@ -600,6 +603,8 @@ enum UnblockEvent {
|
|
|
600
603
|
WorkflowComplete(u32, Box<ChildWorkflowResult>),
|
|
601
604
|
SignalExternal(u32, Option<Failure>),
|
|
602
605
|
CancelExternal(u32, Option<Failure>),
|
|
606
|
+
NexusOperationStart(u32, Box<resolve_nexus_operation_start::Status>),
|
|
607
|
+
NexusOperationComplete(u32, Box<NexusOperationResult>),
|
|
603
608
|
}
|
|
604
609
|
|
|
605
610
|
/// Result of awaiting on a timer
|
|
@@ -697,43 +702,106 @@ impl Unblockable for CancelExternalWfResult {
|
|
|
697
702
|
}
|
|
698
703
|
}
|
|
699
704
|
|
|
705
|
+
type NexusStartResult = Result<StartedNexusOperation, Failure>;
|
|
706
|
+
impl Unblockable for NexusStartResult {
|
|
707
|
+
type OtherDat = NexusUnblockData;
|
|
708
|
+
fn unblock(ue: UnblockEvent, od: Self::OtherDat) -> Self {
|
|
709
|
+
match ue {
|
|
710
|
+
UnblockEvent::NexusOperationStart(_, result) => match *result {
|
|
711
|
+
resolve_nexus_operation_start::Status::OperationId(op_id) => {
|
|
712
|
+
Ok(StartedNexusOperation {
|
|
713
|
+
operation_id: Some(op_id),
|
|
714
|
+
unblock_dat: od,
|
|
715
|
+
})
|
|
716
|
+
}
|
|
717
|
+
resolve_nexus_operation_start::Status::StartedSync(_) => {
|
|
718
|
+
Ok(StartedNexusOperation {
|
|
719
|
+
operation_id: None,
|
|
720
|
+
unblock_dat: od,
|
|
721
|
+
})
|
|
722
|
+
}
|
|
723
|
+
resolve_nexus_operation_start::Status::CancelledBeforeStart(f) => Err(f),
|
|
724
|
+
},
|
|
725
|
+
_ => panic!("Invalid unblock event for nexus operation"),
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
impl Unblockable for NexusOperationResult {
|
|
731
|
+
type OtherDat = ();
|
|
732
|
+
|
|
733
|
+
fn unblock(ue: UnblockEvent, _: Self::OtherDat) -> Self {
|
|
734
|
+
match ue {
|
|
735
|
+
UnblockEvent::NexusOperationComplete(_, result) => *result,
|
|
736
|
+
_ => panic!("Invalid unblock event for nexus operation complete"),
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
700
741
|
/// Identifier for cancellable operations
|
|
701
742
|
#[derive(Debug, Clone)]
|
|
702
|
-
pub enum CancellableID {
|
|
703
|
-
/// Timer sequence number
|
|
743
|
+
pub(crate) enum CancellableID {
|
|
704
744
|
Timer(u32),
|
|
705
|
-
/// Activity sequence number
|
|
706
745
|
Activity(u32),
|
|
707
|
-
/// Activity sequence number
|
|
708
746
|
LocalActivity(u32),
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
747
|
+
ChildWorkflow {
|
|
748
|
+
seqnum: u32,
|
|
749
|
+
reason: String,
|
|
750
|
+
},
|
|
712
751
|
SignalExternalWorkflow(u32),
|
|
713
|
-
/// An external workflow identifier as may have been created by a started child workflow
|
|
714
752
|
ExternalWorkflow {
|
|
715
|
-
/// Sequence number which will be used for the cancel command
|
|
716
753
|
seqnum: u32,
|
|
717
|
-
/// Identifying information about the workflow to be cancelled
|
|
718
754
|
execution: NamespacedWorkflowExecution,
|
|
719
|
-
|
|
720
|
-
only_child: bool,
|
|
755
|
+
reason: String,
|
|
721
756
|
},
|
|
757
|
+
/// A nexus operation (waiting for start)
|
|
758
|
+
NexusOp(u32),
|
|
722
759
|
}
|
|
723
760
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
761
|
+
/// Cancellation IDs that support a reason.
|
|
762
|
+
pub(crate) trait SupportsCancelReason {
|
|
763
|
+
/// Returns a new version of this ID with the provided cancellation reason.
|
|
764
|
+
fn with_reason(self, reason: String) -> CancellableID;
|
|
765
|
+
}
|
|
766
|
+
#[derive(Debug, Clone)]
|
|
767
|
+
pub(crate) enum CancellableIDWithReason {
|
|
768
|
+
ChildWorkflow {
|
|
769
|
+
seqnum: u32,
|
|
770
|
+
},
|
|
771
|
+
ExternalWorkflow {
|
|
772
|
+
seqnum: u32,
|
|
773
|
+
execution: NamespacedWorkflowExecution,
|
|
774
|
+
},
|
|
775
|
+
}
|
|
776
|
+
impl CancellableIDWithReason {
|
|
777
|
+
pub(crate) fn seq_num(&self) -> u32 {
|
|
727
778
|
match self {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
CancellableID::LocalActivity(seq) => *seq,
|
|
731
|
-
CancellableID::ChildWorkflow(seq) => *seq,
|
|
732
|
-
CancellableID::SignalExternalWorkflow(seq) => *seq,
|
|
733
|
-
CancellableID::ExternalWorkflow { seqnum, .. } => *seqnum,
|
|
779
|
+
CancellableIDWithReason::ChildWorkflow { seqnum } => *seqnum,
|
|
780
|
+
CancellableIDWithReason::ExternalWorkflow { seqnum, .. } => *seqnum,
|
|
734
781
|
}
|
|
735
782
|
}
|
|
736
783
|
}
|
|
784
|
+
impl SupportsCancelReason for CancellableIDWithReason {
|
|
785
|
+
fn with_reason(self, reason: String) -> CancellableID {
|
|
786
|
+
match self {
|
|
787
|
+
CancellableIDWithReason::ChildWorkflow { seqnum } => {
|
|
788
|
+
CancellableID::ChildWorkflow { seqnum, reason }
|
|
789
|
+
}
|
|
790
|
+
CancellableIDWithReason::ExternalWorkflow { seqnum, execution } => {
|
|
791
|
+
CancellableID::ExternalWorkflow {
|
|
792
|
+
seqnum,
|
|
793
|
+
execution,
|
|
794
|
+
reason,
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
impl From<CancellableIDWithReason> for CancellableID {
|
|
801
|
+
fn from(v: CancellableIDWithReason) -> Self {
|
|
802
|
+
v.with_reason("".to_string())
|
|
803
|
+
}
|
|
804
|
+
}
|
|
737
805
|
|
|
738
806
|
#[derive(derive_more::From)]
|
|
739
807
|
#[allow(clippy::large_enum_variant)]
|
|
@@ -746,10 +814,14 @@ enum RustWfCmd {
|
|
|
746
814
|
SubscribeChildWorkflowCompletion(CommandSubscribeChildWorkflowCompletion),
|
|
747
815
|
SubscribeSignal(String, UnboundedSender<SignalData>),
|
|
748
816
|
RegisterUpdate(String, UpdateFunctions),
|
|
817
|
+
SubscribeNexusOperationCompletion {
|
|
818
|
+
seq: u32,
|
|
819
|
+
unblocker: oneshot::Sender<UnblockEvent>,
|
|
820
|
+
},
|
|
749
821
|
}
|
|
750
822
|
|
|
751
823
|
struct CommandCreateRequest {
|
|
752
|
-
cmd:
|
|
824
|
+
cmd: WorkflowCommand,
|
|
753
825
|
unblocker: oneshot::Sender<UnblockEvent>,
|
|
754
826
|
}
|
|
755
827
|
|