@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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
use parking_lot::RwLock;
|
|
6
6
|
use slotmap::SlotMap;
|
|
7
|
-
use std::collections::{hash_map::Entry::Vacant
|
|
7
|
+
use std::collections::{HashMap, hash_map::Entry::Vacant};
|
|
8
8
|
|
|
9
9
|
use temporal_sdk_core_protos::temporal::api::workflowservice::v1::PollWorkflowTaskQueueResponse;
|
|
10
10
|
|
|
@@ -109,7 +109,7 @@ impl SlotManagerImpl {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
/// Enables local workers to
|
|
112
|
+
/// Enables local workers to make themselves visible to a shared client instance.
|
|
113
113
|
/// There can only be one worker registered per namespace+queue_name+client, others will get ignored.
|
|
114
114
|
/// It also provides a convenient method to find compatible slots within the collection.
|
|
115
115
|
#[derive(Default, Debug)]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
use crate::{InterceptedMetricsSvc, RawClientLike, WorkflowService};
|
|
2
2
|
use anyhow::{anyhow, bail};
|
|
3
|
-
use std::marker::PhantomData;
|
|
3
|
+
use std::{fmt::Debug, marker::PhantomData};
|
|
4
4
|
use temporal_sdk_core_protos::{
|
|
5
5
|
coresdk::FromPayloadsExt,
|
|
6
6
|
temporal::api::{
|
|
@@ -31,6 +31,19 @@ pub enum WorkflowExecutionResult<T> {
|
|
|
31
31
|
ContinuedAsNew,
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
impl<T> WorkflowExecutionResult<T>
|
|
35
|
+
where
|
|
36
|
+
T: Debug,
|
|
37
|
+
{
|
|
38
|
+
/// Unwrap the result, panicking if it was not a success
|
|
39
|
+
pub fn unwrap_success(self) -> T {
|
|
40
|
+
match self {
|
|
41
|
+
Self::Succeeded(t) => t,
|
|
42
|
+
o => panic!("Expected success, got {:?}", o),
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
/// Options for fetching workflow results
|
|
35
48
|
#[derive(Debug, Clone, Copy)]
|
|
36
49
|
pub struct GetWorkflowResultOpts {
|
|
@@ -96,6 +109,11 @@ where
|
|
|
96
109
|
&self.info
|
|
97
110
|
}
|
|
98
111
|
|
|
112
|
+
/// Get the client attached to this handle
|
|
113
|
+
pub fn client(&self) -> &CT {
|
|
114
|
+
&self.client
|
|
115
|
+
}
|
|
116
|
+
|
|
99
117
|
/// Await the result of the workflow execution
|
|
100
118
|
pub async fn get_workflow_result(
|
|
101
119
|
&self,
|
package/sdk-core/core/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "temporal-sdk-core"
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
authors = ["Spencer Judge <spencer@temporal.io>", "Vitaly Arbuzov <vitaly@temporal.io>"]
|
|
5
|
-
edition = "
|
|
5
|
+
edition = "2024"
|
|
6
6
|
license-file = { workspace = true }
|
|
7
7
|
description = "Library for building new Temporal SDKs"
|
|
8
8
|
homepage = "https://temporal.io/"
|
|
@@ -35,39 +35,39 @@ enum-iterator = "2"
|
|
|
35
35
|
flate2 = { version = "1.0", optional = true }
|
|
36
36
|
futures-util = { version = "0.3", default-features = false }
|
|
37
37
|
futures-channel = { version = "0.3", default-features = false, features = ["std"] }
|
|
38
|
-
governor = "0.
|
|
38
|
+
governor = "0.8"
|
|
39
39
|
http-body-util = { version = "0.1", optional = true }
|
|
40
40
|
hyper = { version = "1.2", optional = true }
|
|
41
41
|
hyper-util = { version = "0.1", features = ["server", "http1", "http2", "tokio"], optional = true }
|
|
42
|
-
itertools = "0.
|
|
43
|
-
lru = "0.
|
|
42
|
+
itertools = "0.14"
|
|
43
|
+
lru = "0.13"
|
|
44
44
|
mockall = "0.13"
|
|
45
45
|
opentelemetry = { workspace = true, features = ["metrics"], optional = true }
|
|
46
|
-
opentelemetry_sdk = { version = "0.
|
|
47
|
-
opentelemetry-otlp = { version = "0.
|
|
48
|
-
opentelemetry-prometheus = {
|
|
46
|
+
opentelemetry_sdk = { version = "0.26", features = ["rt-tokio", "metrics"], optional = true }
|
|
47
|
+
opentelemetry-otlp = { version = "0.26", features = ["tokio", "metrics", "tls", "http-proto", "reqwest-client", ], optional = true }
|
|
48
|
+
opentelemetry-prometheus = { git = "https://github.com/open-telemetry/opentelemetry-rust.git", rev = "e911383", optional = true }
|
|
49
49
|
parking_lot = { version = "0.12", features = ["send_guard"] }
|
|
50
50
|
pid = "4.0"
|
|
51
51
|
pin-project = "1.0"
|
|
52
52
|
prometheus = "0.13"
|
|
53
53
|
prost = { workspace = true }
|
|
54
54
|
prost-types = { version = "0.6", package = "prost-wkt-types" }
|
|
55
|
-
rand = "0.
|
|
55
|
+
rand = "0.9"
|
|
56
56
|
reqwest = { version = "0.12", features = ["json", "stream", "rustls-tls-native-roots"], default-features = false, optional = true }
|
|
57
57
|
ringbuf = "0.4"
|
|
58
58
|
serde = "1.0"
|
|
59
59
|
serde_json = "1.0"
|
|
60
60
|
siphasher = "1.0"
|
|
61
61
|
slotmap = "1.0"
|
|
62
|
-
sysinfo = { version = "0.
|
|
62
|
+
sysinfo = { version = "0.33", default-features = false, features = ["system"] }
|
|
63
63
|
tar = { version = "0.4", optional = true }
|
|
64
|
-
thiserror =
|
|
64
|
+
thiserror = { workspace = true }
|
|
65
65
|
tokio = { version = "1.37", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs", "process"] }
|
|
66
66
|
tokio-util = { version = "0.7", features = ["io", "io-util"] }
|
|
67
67
|
tokio-stream = "0.1"
|
|
68
68
|
tonic = { workspace = true, features = ["tls", "tls-roots"] }
|
|
69
69
|
tracing = "0.1"
|
|
70
|
-
tracing-subscriber = { version = "0.3", features = ["parking_lot", "env-filter", "registry"] }
|
|
70
|
+
tracing-subscriber = { version = "0.3", default-features = false, features = ["parking_lot", "env-filter", "registry", "ansi"] }
|
|
71
71
|
url = "2.2"
|
|
72
72
|
uuid = { version = "1.1", features = ["v4"] }
|
|
73
73
|
zip = { version = "2.0", optional = true }
|
|
@@ -97,15 +97,13 @@ temporal-sdk-core-test-utils = { path = "../test-utils" }
|
|
|
97
97
|
temporal-sdk = { path = "../sdk" }
|
|
98
98
|
tokio-stream = { version = "0.1", features = ["net"] }
|
|
99
99
|
|
|
100
|
-
[build-dependencies]
|
|
101
|
-
tonic-build = { workspace = true }
|
|
102
|
-
|
|
103
100
|
[[test]]
|
|
104
101
|
name = "integ_tests"
|
|
105
102
|
path = "../tests/main.rs"
|
|
106
103
|
# Prevents autodiscovery, and hence these getting run with `cargo test`. Run with
|
|
107
104
|
# `cargo test --test integ_tests`
|
|
108
105
|
test = false
|
|
106
|
+
required-features = ["temporal-sdk-core-protos/serde_serialize"]
|
|
109
107
|
|
|
110
108
|
[[test]]
|
|
111
109
|
name = "heavy_tests"
|
|
@@ -6,8 +6,8 @@ use crate::MetricsContext;
|
|
|
6
6
|
use std::{
|
|
7
7
|
fmt::{Debug, Formatter},
|
|
8
8
|
sync::{
|
|
9
|
-
atomic::{AtomicBool, AtomicUsize, Ordering},
|
|
10
9
|
Arc,
|
|
10
|
+
atomic::{AtomicBool, AtomicUsize, Ordering},
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
use temporal_sdk_core_api::worker::{
|
|
@@ -189,7 +189,7 @@ struct UseCtx<'a, SK: SlotKind> {
|
|
|
189
189
|
permit: &'a SlotSupplierPermit,
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
impl<
|
|
192
|
+
impl<SK: SlotKind> SlotMarkUsedContext for UseCtx<'_, SK> {
|
|
193
193
|
type SlotKind = SK;
|
|
194
194
|
|
|
195
195
|
fn permit(&self) -> &SlotSupplierPermit {
|
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
advance_fut, job_assert, prost_dur,
|
|
2
|
+
ActivityHeartbeat, Worker, advance_fut, job_assert, prost_dur,
|
|
3
3
|
test_help::{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
MockPollCfg, MockWorkerInputs, MocksHolder, QueueResponse, ResponseType, TEST_Q, WorkerExt,
|
|
5
|
+
WorkflowCachingPolicy, build_fake_worker, build_mock_pollers, canned_histories,
|
|
6
|
+
gen_assert_and_reply, mock_manual_poller, mock_poller, mock_poller_from_resps,
|
|
7
|
+
mock_sdk_cfg, mock_worker, poll_and_reply, single_hist_mock_sg, test_worker_cfg,
|
|
8
8
|
},
|
|
9
9
|
worker::client::mocks::{mock_manual_workflow_client, mock_workflow_client},
|
|
10
|
-
ActivityHeartbeat, Worker,
|
|
11
10
|
};
|
|
12
11
|
use futures_util::FutureExt;
|
|
13
12
|
use itertools::Itertools;
|
|
14
13
|
use std::{
|
|
15
14
|
cell::RefCell,
|
|
16
|
-
collections::{
|
|
15
|
+
collections::{HashMap, HashSet, VecDeque, hash_map::Entry},
|
|
17
16
|
future,
|
|
18
17
|
rc::Rc,
|
|
19
18
|
sync::{
|
|
20
|
-
atomic::{AtomicBool, AtomicUsize, Ordering},
|
|
21
19
|
Arc,
|
|
20
|
+
atomic::{AtomicBool, AtomicUsize, Ordering},
|
|
22
21
|
},
|
|
23
22
|
time::Duration,
|
|
24
23
|
};
|
|
25
24
|
use temporal_client::WorkflowOptions;
|
|
26
25
|
use temporal_sdk::{ActivityOptions, WfContext};
|
|
27
26
|
use temporal_sdk_core_api::{
|
|
28
|
-
errors::{CompleteActivityError, PollActivityError},
|
|
29
27
|
Worker as WorkerTrait,
|
|
28
|
+
errors::{CompleteActivityError, PollError},
|
|
30
29
|
};
|
|
31
30
|
use temporal_sdk_core_protos::{
|
|
31
|
+
DEFAULT_ACTIVITY_TYPE, DEFAULT_WORKFLOW_TYPE, TestHistoryBuilder,
|
|
32
32
|
coresdk::{
|
|
33
|
+
ActivityTaskCompletion,
|
|
33
34
|
activity_result::{
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
ActivityExecutionResult, ActivityResolution, Success, activity_execution_result,
|
|
36
|
+
activity_resolution,
|
|
36
37
|
},
|
|
37
|
-
activity_task::{
|
|
38
|
-
workflow_activation::{
|
|
38
|
+
activity_task::{ActivityCancelReason, ActivityTask, Cancel, activity_task},
|
|
39
|
+
workflow_activation::{ResolveActivity, WorkflowActivationJob, workflow_activation_job},
|
|
39
40
|
workflow_commands::{
|
|
40
41
|
ActivityCancellationType, CompleteWorkflowExecution, RequestCancelActivity,
|
|
41
42
|
ScheduleActivity,
|
|
42
43
|
},
|
|
43
44
|
workflow_completion::WorkflowActivationCompletion,
|
|
44
|
-
ActivityTaskCompletion,
|
|
45
45
|
},
|
|
46
46
|
temporal::api::{
|
|
47
|
-
command::v1::{command::Attributes
|
|
48
|
-
enums::v1::EventType,
|
|
47
|
+
command::v1::{ScheduleActivityTaskCommandAttributes, command::Attributes},
|
|
48
|
+
enums::v1::{CommandType, EventType},
|
|
49
49
|
history::v1::{
|
|
50
|
-
history_event::Attributes as EventAttributes,
|
|
50
|
+
ActivityTaskScheduledEventAttributes, history_event::Attributes as EventAttributes,
|
|
51
51
|
},
|
|
52
|
+
sdk::v1::UserMetadata,
|
|
52
53
|
workflowservice::v1::{
|
|
53
54
|
PollActivityTaskQueueResponse, RecordActivityTaskHeartbeatResponse,
|
|
54
55
|
RespondActivityTaskCanceledResponse, RespondActivityTaskCompletedResponse,
|
|
55
56
|
RespondActivityTaskFailedResponse, RespondWorkflowTaskCompletedResponse,
|
|
56
57
|
},
|
|
57
58
|
},
|
|
58
|
-
TestHistoryBuilder, DEFAULT_WORKFLOW_TYPE,
|
|
59
59
|
};
|
|
60
|
-
use temporal_sdk_core_test_utils::{fanout_tasks, start_timer_cmd
|
|
60
|
+
use temporal_sdk_core_test_utils::{TestWorker, fanout_tasks, start_timer_cmd};
|
|
61
61
|
use tokio::{join, sync::Barrier, time::sleep};
|
|
62
62
|
use tokio_util::sync::CancellationToken;
|
|
63
63
|
|
|
@@ -467,13 +467,15 @@ async fn activity_timeout_no_double_resolve() {
|
|
|
467
467
|
&[
|
|
468
468
|
gen_assert_and_reply(
|
|
469
469
|
&job_assert!(workflow_activation_job::Variant::InitializeWorkflow(_)),
|
|
470
|
-
vec![
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
470
|
+
vec![
|
|
471
|
+
ScheduleActivity {
|
|
472
|
+
seq: activity_id,
|
|
473
|
+
activity_id: activity_id.to_string(),
|
|
474
|
+
cancellation_type: ActivityCancellationType::TryCancel as i32,
|
|
475
|
+
..Default::default()
|
|
476
|
+
}
|
|
477
|
+
.into(),
|
|
478
|
+
],
|
|
477
479
|
),
|
|
478
480
|
gen_assert_and_reply(
|
|
479
481
|
&job_assert!(workflow_activation_job::Variant::SignalWorkflow(_)),
|
|
@@ -633,11 +635,11 @@ async fn max_tq_acts_set_passed_to_poll_properly() {
|
|
|
633
635
|
worker.poll_activity_task().await.unwrap();
|
|
634
636
|
}
|
|
635
637
|
|
|
636
|
-
|
|
637
|
-
/// constructor, [mock_worker] will not pass an activity poller to the worker when
|
|
638
|
-
/// `no_remote_activities` is set to `true`.
|
|
638
|
+
#[rstest::rstest]
|
|
639
639
|
#[tokio::test]
|
|
640
|
-
async fn
|
|
640
|
+
async fn no_eager_activities_requested_when_worker_options_disable_it(
|
|
641
|
+
#[values("no_remote", "throttle")] reason: &'static str,
|
|
642
|
+
) {
|
|
641
643
|
let wfid = "fake_wf_id";
|
|
642
644
|
let mut t = TestHistoryBuilder::default();
|
|
643
645
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
@@ -648,7 +650,6 @@ async fn no_eager_activities_requested_when_worker_options_disable_remote_activi
|
|
|
648
650
|
t.add_full_wf_task();
|
|
649
651
|
t.add_workflow_execution_completed();
|
|
650
652
|
let num_eager_requested = Arc::new(AtomicUsize::new(0));
|
|
651
|
-
// Clone it to move into the callback below
|
|
652
653
|
let num_eager_requested_clone = num_eager_requested.clone();
|
|
653
654
|
|
|
654
655
|
let mut mock = mock_workflow_client();
|
|
@@ -677,27 +678,28 @@ async fn no_eager_activities_requested_when_worker_options_disable_remote_activi
|
|
|
677
678
|
})
|
|
678
679
|
});
|
|
679
680
|
let mut mock = single_hist_mock_sg(wfid, t, [1], mock, true);
|
|
680
|
-
let mut mock_poller = mock_manual_poller();
|
|
681
|
-
mock_poller
|
|
682
|
-
.expect_poll()
|
|
683
|
-
.returning(|| futures_util::future::pending().boxed());
|
|
684
|
-
mock.set_act_poller(Box::new(mock_poller));
|
|
685
681
|
mock.worker_cfg(|wc| {
|
|
686
682
|
wc.max_cached_workflows = 2;
|
|
687
|
-
|
|
683
|
+
if reason == "no_remote" {
|
|
684
|
+
wc.no_remote_activities = true;
|
|
685
|
+
} else {
|
|
686
|
+
wc.max_task_queue_activities_per_second = Some(1.0);
|
|
687
|
+
}
|
|
688
688
|
});
|
|
689
689
|
let core = mock_worker(mock);
|
|
690
690
|
|
|
691
691
|
// Test start
|
|
692
692
|
let wf_task = core.poll_workflow_activation().await.unwrap();
|
|
693
|
-
let cmds = vec![
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
693
|
+
let cmds = vec![
|
|
694
|
+
ScheduleActivity {
|
|
695
|
+
seq: 1,
|
|
696
|
+
activity_id: "act_id".to_string(),
|
|
697
|
+
task_queue: TEST_Q.to_string(),
|
|
698
|
+
cancellation_type: ActivityCancellationType::TryCancel as i32,
|
|
699
|
+
..Default::default()
|
|
700
|
+
}
|
|
701
|
+
.into(),
|
|
702
|
+
];
|
|
701
703
|
|
|
702
704
|
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
703
705
|
wf_task.run_id,
|
|
@@ -985,7 +987,7 @@ async fn activity_tasks_from_completion_reserve_slots() {
|
|
|
985
987
|
core.initiate_shutdown();
|
|
986
988
|
// Even though this test requests eager activity tasks, none are returned in poll responses.
|
|
987
989
|
let err = core.poll_activity_task().await.unwrap_err();
|
|
988
|
-
assert_matches!(err,
|
|
990
|
+
assert_matches!(err, PollError::ShutDown);
|
|
989
991
|
};
|
|
990
992
|
// This wf poll should *not* set the flag that it wants tasks back since both slots are
|
|
991
993
|
// occupied
|
|
@@ -1187,3 +1189,54 @@ async fn activities_must_be_flushed_to_server_on_shutdown(#[values(true, false)]
|
|
|
1187
1189
|
};
|
|
1188
1190
|
join!(shutdown_task, complete_task);
|
|
1189
1191
|
}
|
|
1192
|
+
|
|
1193
|
+
#[tokio::test]
|
|
1194
|
+
async fn pass_activity_summary_to_metadata() {
|
|
1195
|
+
let t = canned_histories::single_activity("1");
|
|
1196
|
+
let mut mock_cfg = MockPollCfg::from_hist_builder(t);
|
|
1197
|
+
let wf_id = mock_cfg.hists[0].wf_id.clone();
|
|
1198
|
+
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
1199
|
+
let expected_user_metadata = Some(UserMetadata {
|
|
1200
|
+
summary: Some(b"activity summary".into()),
|
|
1201
|
+
details: None,
|
|
1202
|
+
});
|
|
1203
|
+
mock_cfg.completion_asserts_from_expectations(|mut asserts| {
|
|
1204
|
+
asserts
|
|
1205
|
+
.then(move |wft| {
|
|
1206
|
+
assert_eq!(wft.commands.len(), 1);
|
|
1207
|
+
assert_eq!(
|
|
1208
|
+
wft.commands[0].command_type(),
|
|
1209
|
+
CommandType::ScheduleActivityTask
|
|
1210
|
+
);
|
|
1211
|
+
assert_eq!(wft.commands[0].user_metadata, expected_user_metadata)
|
|
1212
|
+
})
|
|
1213
|
+
.then(move |wft| {
|
|
1214
|
+
assert_eq!(wft.commands.len(), 1);
|
|
1215
|
+
assert_eq!(
|
|
1216
|
+
wft.commands[0].command_type(),
|
|
1217
|
+
CommandType::CompleteWorkflowExecution
|
|
1218
|
+
);
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
let mut worker = mock_sdk_cfg(mock_cfg, |_| {});
|
|
1223
|
+
worker.register_wf(wf_type, |ctx: WfContext| async move {
|
|
1224
|
+
ctx.activity(ActivityOptions {
|
|
1225
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
1226
|
+
summary: Some("activity summary".to_string()),
|
|
1227
|
+
..Default::default()
|
|
1228
|
+
})
|
|
1229
|
+
.await;
|
|
1230
|
+
Ok(().into())
|
|
1231
|
+
});
|
|
1232
|
+
worker
|
|
1233
|
+
.submit_wf(
|
|
1234
|
+
wf_id.to_owned(),
|
|
1235
|
+
wf_type.to_owned(),
|
|
1236
|
+
vec![],
|
|
1237
|
+
WorkflowOptions::default(),
|
|
1238
|
+
)
|
|
1239
|
+
.await
|
|
1240
|
+
.unwrap();
|
|
1241
|
+
worker.run_until_done().await.unwrap();
|
|
1242
|
+
}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
replay::DEFAULT_WORKFLOW_TYPE,
|
|
3
3
|
test_help::{
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
MockPollCfg, ResponseType, build_fake_sdk, canned_histories, mock_sdk, mock_sdk_cfg,
|
|
5
|
+
mock_worker, single_hist_mock_sg,
|
|
6
6
|
},
|
|
7
7
|
worker::client::mocks::mock_workflow_client,
|
|
8
8
|
};
|
|
9
9
|
use temporal_client::WorkflowOptions;
|
|
10
10
|
use temporal_sdk::{ChildWorkflowOptions, Signal, WfContext, WorkflowResult};
|
|
11
11
|
use temporal_sdk_core_api::Worker;
|
|
12
|
-
use temporal_sdk_core_protos::
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
use temporal_sdk_core_protos::{
|
|
13
|
+
coresdk::{
|
|
14
|
+
child_workflow::{ChildWorkflowCancellationType, child_workflow_result},
|
|
15
|
+
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
|
|
16
|
+
workflow_commands::{
|
|
17
|
+
CancelChildWorkflowExecution, CompleteWorkflowExecution, StartChildWorkflowExecution,
|
|
18
|
+
},
|
|
19
|
+
workflow_completion::WorkflowActivationCompletion,
|
|
17
20
|
},
|
|
18
|
-
|
|
21
|
+
temporal::api::{enums::v1::CommandType, sdk::v1::UserMetadata},
|
|
19
22
|
};
|
|
20
23
|
use tokio::join;
|
|
21
24
|
|
|
@@ -89,7 +92,7 @@ async fn parent_cancels_child_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
|
89
92
|
.await
|
|
90
93
|
.into_started()
|
|
91
94
|
.expect("Child should get started");
|
|
92
|
-
start_res.cancel(&ctx);
|
|
95
|
+
start_res.cancel(&ctx, "cancel reason".to_string());
|
|
93
96
|
let stat = start_res
|
|
94
97
|
.result()
|
|
95
98
|
.await
|
|
@@ -154,6 +157,7 @@ async fn cancel_child_workflow_lang_thinks_not_started_but_is(
|
|
|
154
157
|
act.run_id,
|
|
155
158
|
CancelChildWorkflowExecution {
|
|
156
159
|
child_workflow_seq: 1,
|
|
160
|
+
reason: "dieee".to_string(),
|
|
157
161
|
}
|
|
158
162
|
.into(),
|
|
159
163
|
))
|
|
@@ -212,6 +216,7 @@ async fn cancel_already_complete_child_ignored() {
|
|
|
212
216
|
vec![
|
|
213
217
|
CancelChildWorkflowExecution {
|
|
214
218
|
child_workflow_seq: 1,
|
|
219
|
+
reason: "go away!".to_string(),
|
|
215
220
|
}
|
|
216
221
|
.into(),
|
|
217
222
|
CompleteWorkflowExecution { result: None }.into(),
|
|
@@ -220,3 +225,57 @@ async fn cancel_already_complete_child_ignored() {
|
|
|
220
225
|
.await
|
|
221
226
|
.unwrap();
|
|
222
227
|
}
|
|
228
|
+
|
|
229
|
+
#[tokio::test]
|
|
230
|
+
async fn pass_child_workflow_summary_to_metadata() {
|
|
231
|
+
let wf_id = "1";
|
|
232
|
+
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
233
|
+
let t = canned_histories::single_child_workflow(wf_id);
|
|
234
|
+
let mut mock_cfg = MockPollCfg::from_hist_builder(t);
|
|
235
|
+
let expected_user_metadata = Some(UserMetadata {
|
|
236
|
+
summary: Some(b"child summary".into()),
|
|
237
|
+
details: Some(b"child details".into()),
|
|
238
|
+
});
|
|
239
|
+
mock_cfg.completion_asserts_from_expectations(|mut asserts| {
|
|
240
|
+
asserts
|
|
241
|
+
.then(move |wft| {
|
|
242
|
+
assert_eq!(wft.commands.len(), 1);
|
|
243
|
+
assert_eq!(
|
|
244
|
+
wft.commands[0].command_type(),
|
|
245
|
+
CommandType::StartChildWorkflowExecution
|
|
246
|
+
);
|
|
247
|
+
assert_eq!(wft.commands[0].user_metadata, expected_user_metadata)
|
|
248
|
+
})
|
|
249
|
+
.then(move |wft| {
|
|
250
|
+
assert_eq!(wft.commands.len(), 1);
|
|
251
|
+
assert_eq!(
|
|
252
|
+
wft.commands[0].command_type(),
|
|
253
|
+
CommandType::CompleteWorkflowExecution
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
let mut worker = mock_sdk_cfg(mock_cfg, |_| {});
|
|
259
|
+
worker.register_wf(wf_type, move |ctx: WfContext| async move {
|
|
260
|
+
ctx.child_workflow(ChildWorkflowOptions {
|
|
261
|
+
workflow_id: wf_id.to_string(),
|
|
262
|
+
workflow_type: "child".to_string(),
|
|
263
|
+
static_summary: Some("child summary".to_string()),
|
|
264
|
+
static_details: Some("child details".to_string()),
|
|
265
|
+
..Default::default()
|
|
266
|
+
})
|
|
267
|
+
.start(&ctx)
|
|
268
|
+
.await;
|
|
269
|
+
Ok(().into())
|
|
270
|
+
});
|
|
271
|
+
worker
|
|
272
|
+
.submit_wf(
|
|
273
|
+
wf_id.to_owned(),
|
|
274
|
+
wf_type.to_owned(),
|
|
275
|
+
vec![],
|
|
276
|
+
WorkflowOptions::default(),
|
|
277
|
+
)
|
|
278
|
+
.await
|
|
279
|
+
.unwrap();
|
|
280
|
+
worker.run_until_done().await.unwrap();
|
|
281
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
internal_flags::CoreInternalFlags,
|
|
3
3
|
replay::DEFAULT_WORKFLOW_TYPE,
|
|
4
|
-
test_help::{
|
|
4
|
+
test_help::{MockPollCfg, ResponseType, canned_histories, mock_sdk, mock_sdk_cfg},
|
|
5
5
|
worker::client::mocks::mock_workflow_client,
|
|
6
6
|
};
|
|
7
7
|
use std::{
|
|
@@ -13,11 +13,11 @@ use temporal_sdk::{
|
|
|
13
13
|
ActivityOptions, ChildWorkflowOptions, LocalActivityOptions, WfContext, WorkflowResult,
|
|
14
14
|
};
|
|
15
15
|
use temporal_sdk_core_protos::{
|
|
16
|
+
DEFAULT_ACTIVITY_TYPE, TestHistoryBuilder,
|
|
16
17
|
temporal::api::{
|
|
17
18
|
enums::v1::{EventType, WorkflowTaskFailedCause},
|
|
18
19
|
failure::v1::Failure,
|
|
19
20
|
},
|
|
20
|
-
TestHistoryBuilder, DEFAULT_ACTIVITY_TYPE,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
static DID_FAIL: AtomicBool = AtomicBool::new(false);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
prost_dur,
|
|
3
|
-
replay::{
|
|
3
|
+
replay::{DEFAULT_WORKFLOW_TYPE, TestHistoryBuilder, default_wes_attribs},
|
|
4
4
|
test_help::{
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
MockPollCfg, ResponseType, WorkerExt, build_mock_pollers, hist_to_poll_resp, mock_sdk,
|
|
6
|
+
mock_sdk_cfg, mock_worker, single_hist_mock_sg,
|
|
7
7
|
},
|
|
8
|
-
worker::{client::mocks::mock_workflow_client
|
|
8
|
+
worker::{LEGACY_QUERY_ID, client::mocks::mock_workflow_client},
|
|
9
9
|
};
|
|
10
10
|
use anyhow::anyhow;
|
|
11
11
|
use crossbeam_queue::SegQueue;
|
|
12
|
-
use futures_util::{future::join_all
|
|
12
|
+
use futures_util::{FutureExt, future::join_all};
|
|
13
13
|
use std::{
|
|
14
14
|
collections::HashMap,
|
|
15
15
|
ops::Sub,
|
|
16
16
|
sync::{
|
|
17
|
-
atomic::{AtomicUsize, Ordering},
|
|
18
17
|
Arc,
|
|
18
|
+
atomic::{AtomicUsize, Ordering},
|
|
19
19
|
},
|
|
20
20
|
time::{Duration, Instant, SystemTime},
|
|
21
21
|
};
|
|
@@ -23,28 +23,25 @@ use temporal_client::WorkflowOptions;
|
|
|
23
23
|
use temporal_sdk::{
|
|
24
24
|
ActContext, ActivityError, LocalActivityOptions, WfContext, WorkflowFunction, WorkflowResult,
|
|
25
25
|
};
|
|
26
|
-
use temporal_sdk_core_api::{
|
|
27
|
-
errors::{PollActivityError, PollWfError},
|
|
28
|
-
Worker,
|
|
29
|
-
};
|
|
26
|
+
use temporal_sdk_core_api::{Worker, errors::PollError};
|
|
30
27
|
use temporal_sdk_core_protos::{
|
|
28
|
+
DEFAULT_ACTIVITY_TYPE,
|
|
31
29
|
coresdk::{
|
|
30
|
+
ActivityTaskCompletion, AsJsonPayloadExt,
|
|
32
31
|
activity_result::ActivityExecutionResult,
|
|
33
|
-
workflow_activation::{
|
|
32
|
+
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
|
|
34
33
|
workflow_commands::{ActivityCancellationType, ScheduleLocalActivity},
|
|
35
34
|
workflow_completion::WorkflowActivationCompletion,
|
|
36
|
-
ActivityTaskCompletion, AsJsonPayloadExt,
|
|
37
35
|
},
|
|
38
36
|
temporal::api::{
|
|
39
37
|
common::v1::RetryPolicy,
|
|
40
38
|
enums::v1::{CommandType, EventType, TimeoutType, WorkflowTaskFailedCause},
|
|
41
|
-
failure::v1::{failure::FailureInfo
|
|
39
|
+
failure::v1::{Failure, failure::FailureInfo},
|
|
42
40
|
query::v1::WorkflowQuery,
|
|
43
41
|
},
|
|
44
|
-
DEFAULT_ACTIVITY_TYPE,
|
|
45
42
|
};
|
|
46
43
|
use temporal_sdk_core_test_utils::{
|
|
47
|
-
query_ok, schedule_local_activity_cmd, start_timer_cmd,
|
|
44
|
+
WorkerTestHelpers, query_ok, schedule_local_activity_cmd, start_timer_cmd,
|
|
48
45
|
};
|
|
49
46
|
use tokio::{join, select, sync::Barrier};
|
|
50
47
|
|
|
@@ -573,9 +570,6 @@ async fn la_resolve_during_legacy_query_does_not_combine(#[case] impossible_quer
|
|
|
573
570
|
// then next task is incremental w/ legacy query (for impossible query case)
|
|
574
571
|
t.add_full_wf_task();
|
|
575
572
|
|
|
576
|
-
let barr = Arc::new(Barrier::new(2));
|
|
577
|
-
let barr_c = barr.clone();
|
|
578
|
-
|
|
579
573
|
let tasks = [
|
|
580
574
|
hist_to_poll_resp(&t, wfid.to_owned(), ResponseType::ToTaskNum(1)),
|
|
581
575
|
{
|
|
@@ -592,17 +586,7 @@ async fn la_resolve_during_legacy_query_does_not_combine(#[case] impossible_quer
|
|
|
592
586
|
pr
|
|
593
587
|
},
|
|
594
588
|
{
|
|
595
|
-
let mut pr = hist_to_poll_resp(
|
|
596
|
-
&t,
|
|
597
|
-
wfid.to_owned(),
|
|
598
|
-
ResponseType::UntilResolved(
|
|
599
|
-
async move {
|
|
600
|
-
barr_c.wait().await;
|
|
601
|
-
}
|
|
602
|
-
.boxed(),
|
|
603
|
-
2,
|
|
604
|
-
),
|
|
605
|
-
);
|
|
589
|
+
let mut pr = hist_to_poll_resp(&t, wfid.to_owned(), ResponseType::ToTaskNum(2));
|
|
606
590
|
// Strip beginning of history so the only events are WFT sched/started, we need to look
|
|
607
591
|
// like we hit the cache
|
|
608
592
|
{
|
|
@@ -629,6 +613,7 @@ async fn la_resolve_during_legacy_query_does_not_combine(#[case] impossible_quer
|
|
|
629
613
|
}
|
|
630
614
|
let mut mock = single_hist_mock_sg(wfid, t, tasks, mock, true);
|
|
631
615
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 1);
|
|
616
|
+
let taskmap = mock.outstanding_task_map.clone().unwrap();
|
|
632
617
|
let core = mock_worker(mock);
|
|
633
618
|
|
|
634
619
|
let wf_fut = async {
|
|
@@ -653,6 +638,9 @@ async fn la_resolve_during_legacy_query_does_not_combine(#[case] impossible_quer
|
|
|
653
638
|
variant: Some(workflow_activation_job::Variant::FireTimer(_)),
|
|
654
639
|
},]
|
|
655
640
|
);
|
|
641
|
+
// We want to make sure the weird-looking query gets received while we're working on other
|
|
642
|
+
// stuff, so that we don't see the workflow complete and choose to evict.
|
|
643
|
+
taskmap.release_run(&task.run_id);
|
|
656
644
|
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmd(
|
|
657
645
|
task.run_id,
|
|
658
646
|
schedule_local_activity_cmd(
|
|
@@ -691,7 +679,6 @@ async fn la_resolve_during_legacy_query_does_not_combine(#[case] impossible_quer
|
|
|
691
679
|
))
|
|
692
680
|
.await
|
|
693
681
|
.unwrap();
|
|
694
|
-
barr.wait().await;
|
|
695
682
|
|
|
696
683
|
if impossible_query_in_task {
|
|
697
684
|
// finish last query
|
|
@@ -873,7 +860,7 @@ async fn start_to_close_timeout_allows_retries(#[values(true, false)] la_complet
|
|
|
873
860
|
1,
|
|
874
861
|
"1",
|
|
875
862
|
None,
|
|
876
|
-
Some(Failure::
|
|
863
|
+
Some(Failure::timeout(TimeoutType::StartToClose)),
|
|
877
864
|
|_| {},
|
|
878
865
|
);
|
|
879
866
|
}
|
|
@@ -1189,8 +1176,8 @@ async fn local_activities_can_be_delivered_during_shutdown() {
|
|
|
1189
1176
|
};
|
|
1190
1177
|
|
|
1191
1178
|
let (wf_r, act_r) = join!(wf_poller, at_poller);
|
|
1192
|
-
assert_matches!(wf_r.unwrap_err(),
|
|
1193
|
-
assert_matches!(act_r.unwrap_err(),
|
|
1179
|
+
assert_matches!(wf_r.unwrap_err(), PollError::ShutDown);
|
|
1180
|
+
assert_matches!(act_r.unwrap_err(), PollError::ShutDown);
|
|
1194
1181
|
}
|
|
1195
1182
|
|
|
1196
1183
|
#[tokio::test]
|