@temporalio/core-bridge 1.13.0 → 1.13.2
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 +239 -382
- package/Cargo.toml +11 -11
- package/lib/native.d.ts +10 -3
- 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 +71 -11
- package/sdk-core/.clippy.toml +1 -0
- package/sdk-core/.github/workflows/heavy.yml +2 -0
- package/sdk-core/.github/workflows/per-pr.yml +50 -18
- package/sdk-core/ARCHITECTURE.md +44 -48
- package/sdk-core/Cargo.toml +26 -7
- package/sdk-core/README.md +4 -0
- package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
- package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
- package/sdk-core/arch_docs/sdks_intro.md +299 -0
- package/sdk-core/client/Cargo.toml +8 -7
- package/sdk-core/client/src/callback_based.rs +1 -2
- package/sdk-core/client/src/lib.rs +485 -299
- package/sdk-core/client/src/metrics.rs +32 -8
- package/sdk-core/client/src/proxy.rs +124 -5
- package/sdk-core/client/src/raw.rs +598 -307
- package/sdk-core/client/src/replaceable.rs +253 -0
- package/sdk-core/client/src/retry.rs +9 -6
- package/sdk-core/client/src/worker_registry/mod.rs +19 -3
- package/sdk-core/client/src/workflow_handle/mod.rs +20 -17
- package/sdk-core/core/Cargo.toml +100 -31
- package/sdk-core/core/src/core_tests/activity_tasks.rs +55 -225
- package/sdk-core/core/src/core_tests/mod.rs +2 -8
- package/sdk-core/core/src/core_tests/queries.rs +3 -5
- package/sdk-core/core/src/core_tests/replay_flag.rs +3 -62
- package/sdk-core/core/src/core_tests/updates.rs +4 -5
- package/sdk-core/core/src/core_tests/workers.rs +4 -3
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +10 -7
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +28 -291
- package/sdk-core/core/src/ephemeral_server/mod.rs +15 -3
- package/sdk-core/core/src/internal_flags.rs +11 -1
- package/sdk-core/core/src/lib.rs +50 -36
- package/sdk-core/core/src/pollers/mod.rs +5 -5
- package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
- package/sdk-core/core/src/protosext/mod.rs +13 -5
- package/sdk-core/core/src/protosext/protocol_messages.rs +4 -11
- package/sdk-core/core/src/retry_logic.rs +256 -108
- package/sdk-core/core/src/telemetry/metrics.rs +1 -0
- package/sdk-core/core/src/telemetry/mod.rs +8 -2
- package/sdk-core/core/src/telemetry/prometheus_meter.rs +2 -2
- package/sdk-core/core/src/test_help/integ_helpers.rs +971 -0
- package/sdk-core/core/src/test_help/mod.rs +10 -1100
- package/sdk-core/core/src/test_help/unit_helpers.rs +218 -0
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +42 -6
- package/sdk-core/core/src/worker/activities/local_activities.rs +19 -19
- package/sdk-core/core/src/worker/activities.rs +10 -3
- package/sdk-core/core/src/worker/client/mocks.rs +3 -3
- package/sdk-core/core/src/worker/client.rs +130 -93
- package/sdk-core/core/src/worker/heartbeat.rs +12 -13
- package/sdk-core/core/src/worker/mod.rs +31 -21
- package/sdk-core/core/src/worker/nexus.rs +14 -3
- package/sdk-core/core/src/worker/slot_provider.rs +9 -0
- package/sdk-core/core/src/worker/tuner.rs +159 -0
- package/sdk-core/core/src/worker/workflow/history_update.rs +3 -265
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -54
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -82
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -67
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -192
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -43
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +6 -554
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -71
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +102 -3
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +10 -539
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -139
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -119
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -63
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +9 -4
- package/sdk-core/core/src/worker/workflow/mod.rs +5 -1
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +8 -3
- package/sdk-core/core-api/Cargo.toml +4 -4
- package/sdk-core/core-api/src/envconfig.rs +153 -54
- package/sdk-core/core-api/src/lib.rs +68 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +2 -1
- package/sdk-core/core-api/src/telemetry.rs +13 -0
- package/sdk-core/core-c-bridge/Cargo.toml +13 -8
- package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +184 -22
- package/sdk-core/core-c-bridge/src/client.rs +462 -184
- package/sdk-core/core-c-bridge/src/envconfig.rs +314 -0
- package/sdk-core/core-c-bridge/src/lib.rs +1 -0
- package/sdk-core/core-c-bridge/src/random.rs +4 -4
- package/sdk-core/core-c-bridge/src/runtime.rs +22 -23
- package/sdk-core/core-c-bridge/src/testing.rs +1 -4
- package/sdk-core/core-c-bridge/src/tests/context.rs +31 -31
- package/sdk-core/core-c-bridge/src/tests/mod.rs +32 -28
- package/sdk-core/core-c-bridge/src/tests/utils.rs +7 -7
- package/sdk-core/core-c-bridge/src/worker.rs +319 -66
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -1
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +5 -5
- package/sdk-core/sdk/Cargo.toml +8 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/app_data.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -4
- package/sdk-core/sdk/src/lib.rs +1 -5
- package/sdk-core/sdk/src/workflow_context/options.rs +10 -1
- package/sdk-core/sdk/src/workflow_future.rs +1 -1
- package/sdk-core/sdk-core-protos/Cargo.toml +6 -6
- package/sdk-core/sdk-core-protos/build.rs +10 -23
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +9 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +254 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +234 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- package/sdk-core/{test-utils → sdk-core-protos}/src/canned_histories.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -2
- package/sdk-core/sdk-core-protos/src/lib.rs +25 -9
- package/sdk-core/sdk-core-protos/src/test_utils.rs +89 -0
- package/sdk-core/sdk-core-protos/src/utilities.rs +14 -5
- package/sdk-core/tests/c_bridge_smoke_test.c +10 -0
- package/sdk-core/tests/cloud_tests.rs +10 -8
- package/sdk-core/tests/common/http_proxy.rs +134 -0
- package/sdk-core/{test-utils/src/lib.rs → tests/common/mod.rs} +214 -281
- package/sdk-core/{test-utils/src → tests/common}/workflows.rs +4 -3
- package/sdk-core/tests/fuzzy_workflow.rs +1 -1
- package/sdk-core/tests/global_metric_tests.rs +8 -7
- package/sdk-core/tests/heavy_tests.rs +7 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +111 -24
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +14 -9
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/metrics_tests.rs +114 -14
- package/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
- package/sdk-core/tests/integ_tests/polling_tests.rs +311 -93
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/update_tests.rs +13 -7
- package/sdk-core/tests/integ_tests/visibility_tests.rs +26 -9
- package/sdk-core/tests/integ_tests/worker_tests.rs +668 -13
- package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +40 -24
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +244 -11
- package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +78 -2
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +61 -2
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +465 -7
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +41 -2
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +315 -3
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1990 -14
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +65 -2
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +123 -23
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +525 -3
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +65 -16
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +32 -23
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +126 -5
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +1 -2
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +124 -8
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +62 -2
- package/sdk-core/tests/integ_tests/workflow_tests.rs +67 -8
- package/sdk-core/tests/main.rs +26 -17
- package/sdk-core/tests/manual_tests.rs +5 -1
- package/sdk-core/tests/runner.rs +22 -40
- package/sdk-core/tests/shared_tests/mod.rs +1 -1
- package/sdk-core/tests/shared_tests/priority.rs +1 -1
- package/sdk-core/{core/benches/workflow_replay.rs → tests/workflow_replay_bench.rs} +10 -5
- package/src/client.rs +97 -20
- package/src/helpers/callbacks.rs +4 -4
- package/src/helpers/errors.rs +7 -1
- package/src/helpers/handles.rs +1 -0
- package/src/helpers/try_from_js.rs +4 -3
- package/src/lib.rs +3 -2
- package/src/metrics.rs +3 -0
- package/src/runtime.rs +5 -2
- package/src/worker.rs +9 -12
- package/ts/native.ts +13 -3
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
- package/sdk-core/core/src/core_tests/determinism.rs +0 -318
- package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
- package/sdk-core/test-utils/Cargo.toml +0 -38
- package/sdk-core/test-utils/src/histfetch.rs +0 -28
- package/sdk-core/test-utils/src/interceptors.rs +0 -46
|
@@ -5,11 +5,15 @@
|
|
|
5
5
|
pub mod constants;
|
|
6
6
|
pub mod utilities;
|
|
7
7
|
|
|
8
|
+
#[cfg(feature = "test-utilities")]
|
|
9
|
+
pub mod canned_histories;
|
|
8
10
|
#[cfg(feature = "history_builders")]
|
|
9
11
|
mod history_builder;
|
|
10
12
|
#[cfg(feature = "history_builders")]
|
|
11
13
|
mod history_info;
|
|
12
14
|
mod task_token;
|
|
15
|
+
#[cfg(feature = "test-utilities")]
|
|
16
|
+
pub mod test_utils;
|
|
13
17
|
|
|
14
18
|
#[cfg(feature = "history_builders")]
|
|
15
19
|
pub use history_builder::{
|
|
@@ -23,6 +27,8 @@ pub use task_token::TaskToken;
|
|
|
23
27
|
pub static ENCODING_PAYLOAD_KEY: &str = "encoding";
|
|
24
28
|
pub static JSON_ENCODING_VAL: &str = "json/plain";
|
|
25
29
|
pub static PATCHED_MARKER_DETAILS_KEY: &str = "patch-data";
|
|
30
|
+
/// The search attribute key used when registering change versions
|
|
31
|
+
pub static VERSION_SEARCH_ATTR_KEY: &str = "TemporalChangeVersion";
|
|
26
32
|
|
|
27
33
|
#[allow(
|
|
28
34
|
clippy::large_enum_variant,
|
|
@@ -39,7 +45,7 @@ pub mod coresdk {
|
|
|
39
45
|
use crate::{
|
|
40
46
|
ENCODING_PAYLOAD_KEY, JSON_ENCODING_VAL,
|
|
41
47
|
temporal::api::{
|
|
42
|
-
common::v1::{Payload, Payloads, WorkflowExecution},
|
|
48
|
+
common::v1::{Payload, Payloads, RetryPolicy, WorkflowExecution},
|
|
43
49
|
enums::v1::{
|
|
44
50
|
ApplicationErrorCategory, TimeoutType, VersioningBehavior, WorkflowTaskFailedCause,
|
|
45
51
|
},
|
|
@@ -390,7 +396,7 @@ pub mod coresdk {
|
|
|
390
396
|
}
|
|
391
397
|
|
|
392
398
|
pub mod external_data {
|
|
393
|
-
use
|
|
399
|
+
use prost_types::{Duration, Timestamp};
|
|
394
400
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
395
401
|
tonic::include_proto!("coresdk.external_data");
|
|
396
402
|
|
|
@@ -475,6 +481,7 @@ pub mod coresdk {
|
|
|
475
481
|
FromPayloadsExt,
|
|
476
482
|
activity_result::{ActivityResolution, activity_resolution},
|
|
477
483
|
common::NamespacedWorkflowExecution,
|
|
484
|
+
fix_retry_policy,
|
|
478
485
|
workflow_activation::remove_from_cache::EvictionReason,
|
|
479
486
|
},
|
|
480
487
|
temporal::api::{
|
|
@@ -487,7 +494,7 @@ pub mod coresdk {
|
|
|
487
494
|
query::v1::WorkflowQuery,
|
|
488
495
|
},
|
|
489
496
|
};
|
|
490
|
-
use
|
|
497
|
+
use prost_types::Timestamp;
|
|
491
498
|
use std::fmt::{Display, Formatter};
|
|
492
499
|
|
|
493
500
|
tonic::include_proto!("coresdk.workflow_activation");
|
|
@@ -512,6 +519,7 @@ pub mod coresdk {
|
|
|
512
519
|
history_size_bytes: 0,
|
|
513
520
|
continue_as_new_suggested: false,
|
|
514
521
|
deployment_version_for_current_task: None,
|
|
522
|
+
last_sdk_version: String::new(),
|
|
515
523
|
}
|
|
516
524
|
}
|
|
517
525
|
|
|
@@ -739,7 +747,7 @@ pub mod coresdk {
|
|
|
739
747
|
continued_failure: attrs.continued_failure,
|
|
740
748
|
last_completion_result: attrs.last_completion_result,
|
|
741
749
|
first_execution_run_id: attrs.first_execution_run_id,
|
|
742
|
-
retry_policy: attrs.retry_policy,
|
|
750
|
+
retry_policy: attrs.retry_policy.map(fix_retry_policy),
|
|
743
751
|
attempt: attrs.attempt,
|
|
744
752
|
cron_schedule: attrs.cron_schedule,
|
|
745
753
|
workflow_execution_expiration_time: attrs.workflow_execution_expiration_time,
|
|
@@ -1292,7 +1300,7 @@ pub mod coresdk {
|
|
|
1292
1300
|
schedule_to_close_timeout: r.schedule_to_close_timeout,
|
|
1293
1301
|
start_to_close_timeout: r.start_to_close_timeout,
|
|
1294
1302
|
heartbeat_timeout: r.heartbeat_timeout,
|
|
1295
|
-
retry_policy: r.retry_policy,
|
|
1303
|
+
retry_policy: r.retry_policy.map(fix_retry_policy),
|
|
1296
1304
|
priority: r.priority,
|
|
1297
1305
|
is_local: false,
|
|
1298
1306
|
},
|
|
@@ -1572,6 +1580,15 @@ pub mod coresdk {
|
|
|
1572
1580
|
}
|
|
1573
1581
|
}
|
|
1574
1582
|
}
|
|
1583
|
+
|
|
1584
|
+
/// If initial_interval is missing, fills it with zero value to prevent crashes
|
|
1585
|
+
/// (lang assumes that RetryPolicy always has initial_interval set).
|
|
1586
|
+
fn fix_retry_policy(mut retry_policy: RetryPolicy) -> RetryPolicy {
|
|
1587
|
+
if retry_policy.initial_interval.is_none() {
|
|
1588
|
+
retry_policy.initial_interval = Default::default();
|
|
1589
|
+
}
|
|
1590
|
+
retry_policy
|
|
1591
|
+
}
|
|
1575
1592
|
}
|
|
1576
1593
|
|
|
1577
1594
|
// No need to lint these
|
|
@@ -2135,8 +2152,7 @@ pub mod temporal {
|
|
|
2135
2152
|
enums::v1::EventType, history::v1::history_event::Attributes,
|
|
2136
2153
|
};
|
|
2137
2154
|
use anyhow::bail;
|
|
2138
|
-
use
|
|
2139
|
-
use std::fmt::Display;
|
|
2155
|
+
use std::fmt::{Display, Formatter};
|
|
2140
2156
|
|
|
2141
2157
|
tonic::include_proto!("temporal.api.history.v1");
|
|
2142
2158
|
|
|
@@ -2677,8 +2693,8 @@ pub mod temporal {
|
|
|
2677
2693
|
}
|
|
2678
2694
|
|
|
2679
2695
|
fn elapsed_between_prost_times(
|
|
2680
|
-
from:
|
|
2681
|
-
to:
|
|
2696
|
+
from: prost_types::Timestamp,
|
|
2697
|
+
to: prost_types::Timestamp,
|
|
2682
2698
|
) -> Option<Option<Duration>> {
|
|
2683
2699
|
let from: Result<SystemTime, _> = from.try_into();
|
|
2684
2700
|
let to: Result<SystemTime, _> = to.try_into();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//! Test utilities for creating workflow commands and histories
|
|
2
|
+
//! Only available when the test-utilities feature is enabled
|
|
3
|
+
|
|
4
|
+
use crate::{
|
|
5
|
+
DEFAULT_ACTIVITY_TYPE,
|
|
6
|
+
coresdk::workflow_commands::{
|
|
7
|
+
ActivityCancellationType, QueryResult, QuerySuccess, ScheduleActivity,
|
|
8
|
+
ScheduleLocalActivity, StartTimer, workflow_command,
|
|
9
|
+
},
|
|
10
|
+
temporal::api::common::v1::Payload,
|
|
11
|
+
};
|
|
12
|
+
use std::time::Duration;
|
|
13
|
+
|
|
14
|
+
/// Convenience macro for creating prost Duration from std::time::Duration
|
|
15
|
+
#[macro_export]
|
|
16
|
+
macro_rules! prost_dur {
|
|
17
|
+
($dur_call:ident $args:tt) => {
|
|
18
|
+
std::time::Duration::$dur_call$args
|
|
19
|
+
.try_into()
|
|
20
|
+
.expect("test duration fits")
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Create a start timer command for use in tests
|
|
25
|
+
pub fn start_timer_cmd(seq: u32, duration: Duration) -> workflow_command::Variant {
|
|
26
|
+
StartTimer {
|
|
27
|
+
seq,
|
|
28
|
+
start_to_fire_timeout: Some(duration.try_into().expect("duration fits")),
|
|
29
|
+
}
|
|
30
|
+
.into()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Create a schedule activity command for use in tests
|
|
34
|
+
pub fn schedule_activity_cmd(
|
|
35
|
+
seq: u32,
|
|
36
|
+
task_q: &str,
|
|
37
|
+
activity_id: &str,
|
|
38
|
+
cancellation_type: ActivityCancellationType,
|
|
39
|
+
activity_timeout: Duration,
|
|
40
|
+
heartbeat_timeout: Duration,
|
|
41
|
+
) -> workflow_command::Variant {
|
|
42
|
+
ScheduleActivity {
|
|
43
|
+
seq,
|
|
44
|
+
activity_id: activity_id.to_string(),
|
|
45
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
46
|
+
task_queue: task_q.to_owned(),
|
|
47
|
+
schedule_to_start_timeout: Some(activity_timeout.try_into().expect("duration fits")),
|
|
48
|
+
start_to_close_timeout: Some(activity_timeout.try_into().expect("duration fits")),
|
|
49
|
+
schedule_to_close_timeout: Some(activity_timeout.try_into().expect("duration fits")),
|
|
50
|
+
heartbeat_timeout: Some(heartbeat_timeout.try_into().expect("duration fits")),
|
|
51
|
+
cancellation_type: cancellation_type as i32,
|
|
52
|
+
..Default::default()
|
|
53
|
+
}
|
|
54
|
+
.into()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Create a schedule local activity command for use in tests
|
|
58
|
+
pub fn schedule_local_activity_cmd(
|
|
59
|
+
seq: u32,
|
|
60
|
+
activity_id: &str,
|
|
61
|
+
cancellation_type: ActivityCancellationType,
|
|
62
|
+
activity_timeout: Duration,
|
|
63
|
+
) -> workflow_command::Variant {
|
|
64
|
+
ScheduleLocalActivity {
|
|
65
|
+
seq,
|
|
66
|
+
activity_id: activity_id.to_string(),
|
|
67
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
68
|
+
schedule_to_start_timeout: Some(activity_timeout.try_into().expect("duration fits")),
|
|
69
|
+
start_to_close_timeout: Some(activity_timeout.try_into().expect("duration fits")),
|
|
70
|
+
schedule_to_close_timeout: Some(activity_timeout.try_into().expect("duration fits")),
|
|
71
|
+
cancellation_type: cancellation_type as i32,
|
|
72
|
+
..Default::default()
|
|
73
|
+
}
|
|
74
|
+
.into()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// Create a successful query response command for use in tests
|
|
78
|
+
pub fn query_ok(id: impl Into<String>, response: impl Into<Payload>) -> workflow_command::Variant {
|
|
79
|
+
QueryResult {
|
|
80
|
+
query_id: id.into(),
|
|
81
|
+
variant: Some(
|
|
82
|
+
QuerySuccess {
|
|
83
|
+
response: Some(response.into()),
|
|
84
|
+
}
|
|
85
|
+
.into(),
|
|
86
|
+
),
|
|
87
|
+
}
|
|
88
|
+
.into()
|
|
89
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
use std::collections::HashMap;
|
|
2
|
+
|
|
1
3
|
use prost::{EncodeError, Message};
|
|
2
4
|
|
|
3
5
|
pub trait TryIntoOrNone<F, T> {
|
|
@@ -18,11 +20,18 @@ where
|
|
|
18
20
|
/// Use to encode an message into a proto `Any`.
|
|
19
21
|
///
|
|
20
22
|
/// Delete this once `prost_wkt_types` supports `prost` `0.12.x` which has built-in any packing.
|
|
21
|
-
pub fn pack_any<T: Message>(
|
|
22
|
-
type_url: String,
|
|
23
|
-
msg: &T,
|
|
24
|
-
) -> Result<prost_wkt_types::Any, EncodeError> {
|
|
23
|
+
pub fn pack_any<T: Message>(type_url: String, msg: &T) -> Result<prost_types::Any, EncodeError> {
|
|
25
24
|
let mut value = Vec::new();
|
|
26
25
|
Message::encode(msg, &mut value)?;
|
|
27
|
-
Ok(
|
|
26
|
+
Ok(prost_types::Any { type_url, value })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Given a header map, lowercase all the keys and return it as a new map.
|
|
30
|
+
/// Any keys that are duplicated after lowercasing will clobber each other in undefined ordering.
|
|
31
|
+
pub fn normalize_http_headers(headers: HashMap<String, String>) -> HashMap<String, String> {
|
|
32
|
+
let mut new_headers = HashMap::new();
|
|
33
|
+
for (header_key, val) in headers.into_iter() {
|
|
34
|
+
new_headers.insert(header_key.to_lowercase(), val);
|
|
35
|
+
}
|
|
36
|
+
new_headers
|
|
28
37
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#include "temporal-sdk-core-c-bridge.h"
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
int main(void) {
|
|
5
|
+
// Just do something simple to confirm the bridge works
|
|
6
|
+
struct TemporalCoreCancellationToken *tok = temporal_core_cancellation_token_new();
|
|
7
|
+
temporal_core_cancellation_token_free(tok);
|
|
8
|
+
printf("C bridge smoke test passed!\n");
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// All non-main.rs tests ignore dead common code so that the linter doesn't complain about about it.
|
|
2
|
+
#[allow(dead_code)]
|
|
3
|
+
mod common;
|
|
4
4
|
mod shared_tests;
|
|
5
5
|
|
|
6
|
+
use common::get_cloud_client;
|
|
7
|
+
use temporal_client::WorkflowClientTrait;
|
|
8
|
+
|
|
6
9
|
#[tokio::test]
|
|
7
10
|
async fn tls_test() {
|
|
8
11
|
let con = get_cloud_client().await;
|
|
@@ -16,8 +19,7 @@ async fn grpc_message_too_large_test() {
|
|
|
16
19
|
shared_tests::grpc_message_too_large().await
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// }
|
|
22
|
+
#[tokio::test]
|
|
23
|
+
async fn priority_values_sent_to_server() {
|
|
24
|
+
shared_tests::priority::priority_values_sent_to_server().await
|
|
25
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
use bytes::Bytes;
|
|
2
|
+
use http_body_util::Empty;
|
|
3
|
+
use hyper::{
|
|
4
|
+
Request, Response, StatusCode, body::Incoming, server::conn::http1, service::service_fn,
|
|
5
|
+
};
|
|
6
|
+
use hyper_util::rt::TokioIo;
|
|
7
|
+
use std::{
|
|
8
|
+
io,
|
|
9
|
+
sync::{
|
|
10
|
+
Arc,
|
|
11
|
+
atomic::{AtomicUsize, Ordering},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
use temporal_client::proxy::ProxyStream;
|
|
15
|
+
#[cfg(unix)]
|
|
16
|
+
use tokio::net::UnixListener;
|
|
17
|
+
use tokio::{
|
|
18
|
+
net::{TcpListener, TcpStream},
|
|
19
|
+
sync::oneshot,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
pub(crate) struct HttpProxy {
|
|
23
|
+
proxy_hits: Arc<AtomicUsize>,
|
|
24
|
+
shutdown_tx: oneshot::Sender<()>,
|
|
25
|
+
}
|
|
26
|
+
impl HttpProxy {
|
|
27
|
+
pub(crate) fn spawn_tcp(listener: TcpListener) -> Self {
|
|
28
|
+
Self::spawn(ProxyListener::Tcp(listener))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#[cfg(unix)]
|
|
32
|
+
pub(crate) fn spawn_unix(listener: UnixListener) -> Self {
|
|
33
|
+
Self::spawn(ProxyListener::Unix(listener))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fn spawn(listener: ProxyListener) -> Self {
|
|
37
|
+
let (shutdown_tx, mut shutdown_rx) = oneshot::channel::<()>();
|
|
38
|
+
let proxy_hits = Arc::new(AtomicUsize::new(0));
|
|
39
|
+
let proxy_hits_cloned = proxy_hits.clone();
|
|
40
|
+
tokio::spawn(async move {
|
|
41
|
+
loop {
|
|
42
|
+
let proxy_hits_cloned = proxy_hits_cloned.clone();
|
|
43
|
+
tokio::select! {
|
|
44
|
+
_ = &mut shutdown_rx => break,
|
|
45
|
+
stream = listener.accept() => {
|
|
46
|
+
let stream = match stream {
|
|
47
|
+
Ok(stream) => stream,
|
|
48
|
+
Err(e) => { println!("Proxy accept error: {e}"); continue; }
|
|
49
|
+
};
|
|
50
|
+
tokio::spawn(async move {
|
|
51
|
+
if let Err(e) = http1::Builder::new()
|
|
52
|
+
.serve_connection(
|
|
53
|
+
TokioIo::new(stream),
|
|
54
|
+
service_fn(move |req| handle_connect(req, proxy_hits_cloned.clone())),
|
|
55
|
+
)
|
|
56
|
+
.with_upgrades()
|
|
57
|
+
.await
|
|
58
|
+
{
|
|
59
|
+
println!("Proxy conn error: {e}");
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Self {
|
|
67
|
+
proxy_hits,
|
|
68
|
+
shutdown_tx,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pub(crate) fn hit_count(&self) -> usize {
|
|
73
|
+
self.proxy_hits.load(Ordering::SeqCst)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Returns before shutdown occurs
|
|
77
|
+
pub(crate) fn shutdown(self) {
|
|
78
|
+
let _ = self.shutdown_tx.send(());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async fn handle_connect(
|
|
83
|
+
req: Request<Incoming>,
|
|
84
|
+
counter: Arc<AtomicUsize>,
|
|
85
|
+
) -> Result<Response<Empty<Bytes>>, hyper::Error> {
|
|
86
|
+
if req.method() == hyper::Method::CONNECT {
|
|
87
|
+
// Increment atomic counter
|
|
88
|
+
counter.fetch_add(1, Ordering::SeqCst);
|
|
89
|
+
|
|
90
|
+
// Tell the client the tunnel is established
|
|
91
|
+
tokio::spawn(async move {
|
|
92
|
+
if let Some(addr) = req.uri().authority().map(|a| a.as_str()) {
|
|
93
|
+
match TcpStream::connect(addr).await {
|
|
94
|
+
Ok(mut server_stream) => match hyper::upgrade::on(req).await {
|
|
95
|
+
Ok(upgraded) => {
|
|
96
|
+
let mut upgraded = TokioIo::new(upgraded);
|
|
97
|
+
let _ =
|
|
98
|
+
tokio::io::copy_bidirectional(&mut upgraded, &mut server_stream)
|
|
99
|
+
.await;
|
|
100
|
+
}
|
|
101
|
+
Err(err) => println!("Upgrade failed: {err}"),
|
|
102
|
+
},
|
|
103
|
+
Err(e) => println!("Failed to connect to {addr}: {e}"),
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
Ok(Response::builder()
|
|
109
|
+
.status(StatusCode::OK)
|
|
110
|
+
.body(Empty::new())
|
|
111
|
+
.unwrap())
|
|
112
|
+
} else {
|
|
113
|
+
Ok(Response::builder()
|
|
114
|
+
.status(StatusCode::METHOD_NOT_ALLOWED)
|
|
115
|
+
.body(Empty::new())
|
|
116
|
+
.unwrap())
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
enum ProxyListener {
|
|
121
|
+
Tcp(TcpListener),
|
|
122
|
+
#[cfg(unix)]
|
|
123
|
+
Unix(UnixListener),
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
impl ProxyListener {
|
|
127
|
+
async fn accept(&self) -> io::Result<ProxyStream> {
|
|
128
|
+
match self {
|
|
129
|
+
ProxyListener::Tcp(tcp) => tcp.accept().await.map(|(s, _)| ProxyStream::Tcp(s)),
|
|
130
|
+
#[cfg(unix)]
|
|
131
|
+
ProxyListener::Unix(unix) => unix.accept().await.map(|(s, _)| ProxyStream::Unix(s)),
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|