@temporalio/core-bridge 1.14.2-canary-release-testing.0 → 1.16.0
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 +794 -650
- package/bridge-macros/src/derive_tryintojs.rs +40 -0
- package/lib/native.d.ts +24 -3
- package/package.json +4 -4
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.github/workflows/per-pr.yml +6 -6
- package/sdk-core/AGENTS.md +42 -31
- package/sdk-core/Cargo.toml +4 -1
- package/sdk-core/README.md +19 -13
- package/sdk-core/crates/client/Cargo.toml +4 -0
- package/sdk-core/crates/client/README.md +139 -0
- package/sdk-core/crates/client/src/async_activity_handle.rs +297 -0
- package/sdk-core/crates/client/src/callback_based.rs +7 -0
- package/sdk-core/crates/client/src/errors.rs +294 -0
- package/sdk-core/crates/client/src/{raw.rs → grpc.rs} +370 -159
- package/sdk-core/crates/client/src/lib.rs +920 -1326
- package/sdk-core/crates/client/src/metrics.rs +24 -33
- package/sdk-core/crates/client/src/options_structs.rs +457 -0
- package/sdk-core/crates/client/src/replaceable.rs +5 -4
- package/sdk-core/crates/client/src/request_extensions.rs +8 -9
- package/sdk-core/crates/client/src/retry.rs +99 -54
- package/sdk-core/crates/client/src/{worker/mod.rs → worker.rs} +104 -29
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +62 -3
- package/sdk-core/crates/common/build.rs +742 -12
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/ci.yml +2 -0
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/create-release.yml +0 -5
- package/sdk-core/crates/common/protos/api_upstream/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/README.md +8 -0
- package/sdk-core/crates/common/protos/api_upstream/cmd/check-path-conflicts/main.go +137 -0
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv2.json +3329 -2647
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +2734 -708
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/activity/v1/message.proto +155 -3
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/command/v1/message.proto +26 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/common/v1/message.proto +8 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +27 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/activity.proto +81 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/event_type.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +15 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +63 -15
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/errordetails/v1/message.proto +8 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/history/v1/message.proto +111 -17
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +21 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +20 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/worker/v1/message.proto +4 -7
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflow/v1/message.proto +80 -22
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +347 -23
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +242 -43
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/core_interface.proto +15 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +9 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +8 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +22 -5
- package/sdk-core/crates/common/src/activity_definition.rs +20 -0
- package/sdk-core/crates/common/src/data_converters.rs +770 -0
- package/sdk-core/crates/common/src/envconfig.rs +5 -0
- package/sdk-core/crates/common/src/lib.rs +15 -211
- package/sdk-core/crates/common/src/payload_visitor.rs +648 -0
- package/sdk-core/crates/common/src/priority.rs +110 -0
- package/sdk-core/crates/common/src/protos/canned_histories.rs +19 -0
- package/sdk-core/crates/common/src/protos/history_builder.rs +45 -0
- package/sdk-core/crates/common/src/protos/history_info.rs +2 -0
- package/sdk-core/crates/common/src/protos/mod.rs +134 -27
- package/sdk-core/crates/common/src/protos/task_token.rs +3 -3
- package/sdk-core/crates/common/src/protos/utilities.rs +11 -0
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/log_export.rs +11 -16
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +272 -225
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/otel.rs +8 -13
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_meter.rs +49 -50
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_server.rs +2 -3
- package/sdk-core/crates/common/src/telemetry.rs +278 -19
- package/sdk-core/crates/common/src/worker.rs +68 -636
- package/sdk-core/crates/common/src/workflow_definition.rs +60 -0
- package/sdk-core/crates/macros/Cargo.toml +5 -1
- package/sdk-core/crates/macros/src/activities_definitions.rs +585 -0
- package/sdk-core/crates/macros/src/fsm_impl.rs +507 -0
- package/sdk-core/crates/macros/src/lib.rs +138 -512
- package/sdk-core/crates/macros/src/macro_utils.rs +106 -0
- package/sdk-core/crates/macros/src/workflow_definitions.rs +1224 -0
- package/sdk-core/crates/sdk/Cargo.toml +19 -6
- package/sdk-core/crates/sdk/README.md +415 -0
- package/sdk-core/crates/sdk/src/activities.rs +417 -0
- package/sdk-core/crates/sdk/src/interceptors.rs +1 -1
- package/sdk-core/crates/sdk/src/lib.rs +759 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +64 -35
- package/sdk-core/crates/sdk/src/workflow_context.rs +1033 -289
- package/sdk-core/crates/sdk/src/workflow_future.rs +277 -213
- package/sdk-core/crates/sdk/src/workflows.rs +711 -0
- package/sdk-core/crates/sdk-core/Cargo.toml +59 -65
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +45 -54
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +1 -1
- package/sdk-core/crates/sdk-core/src/abstractions.rs +6 -10
- package/sdk-core/crates/sdk-core/src/core_tests/activity_tasks.rs +6 -5
- package/sdk-core/crates/sdk-core/src/core_tests/mod.rs +22 -21
- package/sdk-core/crates/sdk-core/src/core_tests/queries.rs +21 -25
- package/sdk-core/crates/sdk-core/src/core_tests/replay_flag.rs +7 -10
- package/sdk-core/crates/sdk-core/src/core_tests/updates.rs +14 -17
- package/sdk-core/crates/sdk-core/src/core_tests/workers.rs +647 -27
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +46 -41
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +13 -16
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +60 -123
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +411 -32
- package/sdk-core/crates/sdk-core/src/protosext/mod.rs +2 -2
- package/sdk-core/crates/sdk-core/src/replay/mod.rs +14 -5
- package/sdk-core/crates/sdk-core/src/telemetry/metrics.rs +183 -198
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -281
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +35 -16
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- package/sdk-core/crates/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +1 -0
- package/sdk-core/crates/sdk-core/src/worker/activities/local_activities.rs +11 -14
- package/sdk-core/crates/sdk-core/src/worker/activities.rs +16 -19
- package/sdk-core/crates/sdk-core/src/worker/client/mocks.rs +11 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +104 -86
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +10 -14
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1175 -241
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +150 -23
- package/sdk-core/crates/sdk-core/src/worker/slot_provider.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/fixed_size.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/resource_based.rs +25 -27
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +64 -44
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +5 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +21 -22
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs +28 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +20 -41
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +50 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/run_cache.rs +4 -7
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_extraction.rs +2 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_poller.rs +8 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/workflow_stream.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/activities_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/basic_pass.rs +54 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.rs +18 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/multi_arg_pass.rs +48 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_input_pass.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_return_type_pass.rs +19 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +14 -5
- package/sdk-core/crates/sdk-core/tests/common/activity_functions.rs +55 -0
- package/sdk-core/crates/sdk-core/tests/common/mod.rs +281 -236
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +9 -14
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -66
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +306 -268
- package/sdk-core/crates/sdk-core/tests/integ_tests/async_activity_client_tests.rs +230 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/client_tests.rs +94 -57
- package/sdk-core/crates/sdk-core/tests/integ_tests/data_converter_tests.rs +381 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +37 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +49 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +447 -300
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +50 -45
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +157 -157
- package/sdk-core/crates/sdk-core/tests/integ_tests/queries_tests.rs +103 -89
- package/sdk-core/crates/sdk-core/tests/integ_tests/update_tests.rs +609 -463
- package/sdk-core/crates/sdk-core/tests/integ_tests/visibility_tests.rs +80 -62
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +389 -265
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +250 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -49
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_client_tests.rs +180 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/activities.rs +437 -327
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -58
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -30
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -251
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/client_interactions.rs +552 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +110 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -149
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -32
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1040
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -43
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +402 -245
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +343 -207
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/queries.rs +415 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/replay.rs +96 -36
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs +155 -140
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -113
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -44
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -48
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +365 -242
- package/sdk-core/crates/sdk-core/tests/main.rs +22 -16
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +233 -187
- package/sdk-core/crates/sdk-core/tests/runner.rs +4 -6
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +73 -27
- package/sdk-core/crates/sdk-core/tests/shared_tests/priority.rs +107 -84
- package/sdk-core/crates/sdk-core/tests/workflows_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/basic_pass.rs +49 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/minimal_pass.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +8 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +37 -26
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +180 -87
- package/sdk-core/crates/sdk-core-c-bridge/src/lib.rs +89 -5
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +10 -16
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +59 -67
- package/sdk-core/crates/sdk-core-c-bridge/src/testing.rs +10 -10
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +57 -22
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +108 -12
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +9 -52
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +74 -91
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +206 -289
- package/src/helpers/try_into_js.rs +88 -2
- package/src/metrics.rs +277 -35
- package/src/runtime.rs +94 -45
- package/src/testing.rs +9 -16
- package/src/worker.rs +86 -68
- package/ts/native.ts +39 -3
- package/sdk-core/crates/client/src/workflow_handle/mod.rs +0 -212
- package/sdk-core/crates/common/src/errors.rs +0 -85
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +0 -129
- package/sdk-core/crates/macros/LICENSE.txt +0 -21
- package/sdk-core/crates/sdk/src/activity_context.rs +0 -238
- package/sdk-core/crates/sdk/src/app_data.rs +0 -37
- package/sdk-core/crates/sdk-core/tests/integ_tests/activity_functions.rs +0 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
PollWorkflowOptions, Worker, advance_fut,
|
|
2
|
+
PollError, PollWorkflowOptions, Worker, advance_fut,
|
|
3
3
|
internal_flags::CoreInternalFlags,
|
|
4
4
|
job_assert,
|
|
5
5
|
replay::TestHistoryBuilder,
|
|
@@ -11,7 +11,8 @@ use crate::{
|
|
|
11
11
|
poll_and_reply_clears_outstanding_evicts, single_hist_mock_sg, test_worker_cfg,
|
|
12
12
|
},
|
|
13
13
|
worker::{
|
|
14
|
-
|
|
14
|
+
PollerBehavior, SlotMarkUsedContext, SlotReleaseContext, SlotReservationContext,
|
|
15
|
+
SlotSupplier, SlotSupplierPermit, TunerBuilder, WorkflowSlotKind,
|
|
15
16
|
client::mocks::{mock_manual_worker_client, mock_worker_client},
|
|
16
17
|
},
|
|
17
18
|
};
|
|
@@ -29,8 +30,6 @@ use std::{
|
|
|
29
30
|
};
|
|
30
31
|
use temporalio_client::MESSAGE_TOO_LARGE_KEY;
|
|
31
32
|
use temporalio_common::{
|
|
32
|
-
Worker as WorkerTrait,
|
|
33
|
-
errors::PollError,
|
|
34
33
|
protos::{
|
|
35
34
|
canned_histories,
|
|
36
35
|
coresdk::{
|
|
@@ -64,10 +63,7 @@ use temporalio_common::{
|
|
|
64
63
|
},
|
|
65
64
|
test_utils::start_timer_cmd,
|
|
66
65
|
},
|
|
67
|
-
worker::
|
|
68
|
-
PollerBehavior, SlotMarkUsedContext, SlotReleaseContext, SlotReservationContext,
|
|
69
|
-
SlotSupplier, SlotSupplierPermit, WorkerTaskTypes, WorkflowSlotKind,
|
|
70
|
-
},
|
|
66
|
+
worker::WorkerTaskTypes,
|
|
71
67
|
};
|
|
72
68
|
use tokio::{
|
|
73
69
|
join,
|
|
@@ -1621,6 +1617,7 @@ async fn history_byte_size_and_can_suggestion_in_activation() {
|
|
|
1621
1617
|
he.attributes
|
|
1622
1618
|
{
|
|
1623
1619
|
attrs.suggest_continue_as_new = true;
|
|
1620
|
+
attrs.suggest_continue_as_new_reasons = vec![1, 2, 3, 4]
|
|
1624
1621
|
}
|
|
1625
1622
|
});
|
|
1626
1623
|
|
|
@@ -1645,6 +1642,7 @@ async fn history_byte_size_and_can_suggestion_in_activation() {
|
|
|
1645
1642
|
let activation = worker.poll_workflow_activation().await.unwrap();
|
|
1646
1643
|
assert_eq!(activation.history_size_bytes, 70);
|
|
1647
1644
|
assert!(activation.continue_as_new_suggested);
|
|
1645
|
+
assert_eq!(activation.suggest_continue_as_new_reasons, vec![1, 2, 3, 4])
|
|
1648
1646
|
}
|
|
1649
1647
|
|
|
1650
1648
|
/// This test verifies that WFTs which come as replies to completing a WFT are properly delivered
|
|
@@ -2022,12 +2020,15 @@ async fn no_race_acquiring_permits() {
|
|
|
2022
2020
|
.returning(|_| async move { Ok(Default::default()) }.boxed());
|
|
2023
2021
|
|
|
2024
2022
|
let worker = Worker::new_test(
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2023
|
+
{
|
|
2024
|
+
let mut cfg = test_worker_cfg()
|
|
2025
|
+
.max_outstanding_workflow_tasks(2_usize)
|
|
2026
|
+
.max_cached_workflows(0_usize)
|
|
2027
|
+
.build()
|
|
2028
|
+
.unwrap();
|
|
2029
|
+
cfg.ignore_evicts_on_shutdown = false;
|
|
2030
|
+
cfg
|
|
2031
|
+
},
|
|
2031
2032
|
mock_client,
|
|
2032
2033
|
);
|
|
2033
2034
|
|
|
@@ -2667,13 +2668,14 @@ async fn poller_wont_run_ahead_of_task_slots() {
|
|
|
2667
2668
|
.returning(|_| Ok(Default::default()));
|
|
2668
2669
|
|
|
2669
2670
|
let worker = Worker::new_test(
|
|
2670
|
-
|
|
2671
|
-
.
|
|
2672
|
-
.
|
|
2673
|
-
.
|
|
2674
|
-
.
|
|
2675
|
-
.
|
|
2676
|
-
|
|
2671
|
+
{
|
|
2672
|
+
let mut cfg = test_worker_cfg().build().unwrap();
|
|
2673
|
+
cfg.max_cached_workflows = 10_usize;
|
|
2674
|
+
cfg.max_outstanding_workflow_tasks = Some(10_usize);
|
|
2675
|
+
cfg.workflow_task_poller_behavior = PollerBehavior::SimpleMaximum(10_usize);
|
|
2676
|
+
cfg.task_types = WorkerTaskTypes::workflow_only();
|
|
2677
|
+
cfg
|
|
2678
|
+
},
|
|
2677
2679
|
mock_client,
|
|
2678
2680
|
);
|
|
2679
2681
|
|
|
@@ -2730,10 +2732,11 @@ async fn poller_wont_poll_until_lang_polls() {
|
|
|
2730
2732
|
});
|
|
2731
2733
|
|
|
2732
2734
|
let worker = Worker::new_test(
|
|
2733
|
-
|
|
2734
|
-
.
|
|
2735
|
-
.
|
|
2736
|
-
|
|
2735
|
+
{
|
|
2736
|
+
let mut cfg = test_worker_cfg().build().unwrap();
|
|
2737
|
+
cfg.task_types = WorkerTaskTypes::workflow_only();
|
|
2738
|
+
cfg
|
|
2739
|
+
},
|
|
2737
2740
|
mock_client,
|
|
2738
2741
|
);
|
|
2739
2742
|
|
|
@@ -2868,17 +2871,18 @@ async fn slot_provider_cant_hand_out_more_permits_than_cache_size() {
|
|
|
2868
2871
|
}
|
|
2869
2872
|
|
|
2870
2873
|
let worker = Worker::new_test(
|
|
2871
|
-
|
|
2872
|
-
.
|
|
2873
|
-
.
|
|
2874
|
+
{
|
|
2875
|
+
let mut cfg = test_worker_cfg().build().unwrap();
|
|
2876
|
+
cfg.max_cached_workflows = 10_usize;
|
|
2877
|
+
cfg.tuner = Some(Arc::new(
|
|
2874
2878
|
TunerBuilder::default()
|
|
2875
2879
|
.workflow_slot_supplier(Arc::new(EndlessSupplier {}))
|
|
2876
2880
|
.build(),
|
|
2877
|
-
))
|
|
2878
|
-
.workflow_task_poller_behavior
|
|
2879
|
-
.task_types
|
|
2880
|
-
|
|
2881
|
-
|
|
2881
|
+
));
|
|
2882
|
+
cfg.workflow_task_poller_behavior = PollerBehavior::SimpleMaximum(10_usize);
|
|
2883
|
+
cfg.task_types = WorkerTaskTypes::workflow_only();
|
|
2884
|
+
cfg
|
|
2885
|
+
},
|
|
2882
2886
|
mock_client,
|
|
2883
2887
|
);
|
|
2884
2888
|
|
|
@@ -3019,14 +3023,15 @@ async fn both_normal_and_sticky_pollers_poll_concurrently() {
|
|
|
3019
3023
|
});
|
|
3020
3024
|
|
|
3021
3025
|
let worker = Worker::new(
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
.
|
|
3025
|
-
.
|
|
3026
|
-
.
|
|
3027
|
-
.
|
|
3028
|
-
.
|
|
3029
|
-
|
|
3026
|
+
{
|
|
3027
|
+
let mut cfg = test_worker_cfg().build().unwrap();
|
|
3028
|
+
cfg.max_cached_workflows = 500_usize; // We need cache, but don't want to deal with evictions
|
|
3029
|
+
cfg.max_outstanding_workflow_tasks = Some(2_usize);
|
|
3030
|
+
cfg.workflow_task_poller_behavior = PollerBehavior::SimpleMaximum(2_usize);
|
|
3031
|
+
cfg.nonsticky_to_sticky_poll_ratio = 0.2;
|
|
3032
|
+
cfg.task_types = WorkerTaskTypes::workflow_only();
|
|
3033
|
+
cfg
|
|
3034
|
+
},
|
|
3030
3035
|
Some("stickytq".to_string()),
|
|
3031
3036
|
Arc::new(mock_client),
|
|
3032
3037
|
None,
|
|
@@ -10,7 +10,7 @@ use std::{
|
|
|
10
10
|
io,
|
|
11
11
|
path::{Path, PathBuf},
|
|
12
12
|
};
|
|
13
|
-
use temporalio_client::
|
|
13
|
+
use temporalio_client::{Connection, ConnectionOptions};
|
|
14
14
|
use tokio::{
|
|
15
15
|
task::spawn_blocking,
|
|
16
16
|
time::{Duration, sleep},
|
|
@@ -24,30 +24,28 @@ use std::os::unix::fs::OpenOptionsExt;
|
|
|
24
24
|
use std::process::Stdio;
|
|
25
25
|
|
|
26
26
|
/// Configuration for Temporal CLI dev server.
|
|
27
|
-
#[derive(Debug, Clone,
|
|
27
|
+
#[derive(Debug, Clone, bon::Builder)]
|
|
28
|
+
#[builder(on(String, into))]
|
|
28
29
|
pub struct TemporalDevServerConfig {
|
|
29
30
|
/// Required path to executable or download info.
|
|
30
31
|
pub exe: EphemeralExe,
|
|
31
32
|
/// Namespace to use.
|
|
32
|
-
#[builder(default = "
|
|
33
|
+
#[builder(default = "default".to_owned())]
|
|
33
34
|
pub namespace: String,
|
|
34
35
|
/// IP to bind to.
|
|
35
|
-
#[builder(default = "
|
|
36
|
+
#[builder(default = "127.0.0.1".to_owned())]
|
|
36
37
|
pub ip: String,
|
|
37
38
|
/// Port to use or obtains a free one if none given.
|
|
38
|
-
#[builder(default)]
|
|
39
39
|
pub port: Option<u16>,
|
|
40
40
|
/// Port to use for the UI server or obtains a free one if none given.
|
|
41
|
-
#[builder(default)]
|
|
42
41
|
pub ui_port: Option<u16>,
|
|
43
42
|
/// Sqlite DB filename if persisting or non-persistent if none.
|
|
44
|
-
#[builder(default)]
|
|
45
43
|
pub db_filename: Option<String>,
|
|
46
44
|
/// Whether to enable the UI. If ui_port is set, assumes true.
|
|
47
45
|
#[builder(default)]
|
|
48
46
|
pub ui: bool,
|
|
49
47
|
/// Log format and level
|
|
50
|
-
#[builder(default =
|
|
48
|
+
#[builder(default = ("pretty".to_owned(), "warn".to_owned()))]
|
|
51
49
|
pub log: (String, String),
|
|
52
50
|
/// Additional arguments to Temporal dev server.
|
|
53
51
|
#[builder(default)]
|
|
@@ -131,12 +129,11 @@ impl TemporalDevServerConfig {
|
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
/// Configuration for the test server.
|
|
134
|
-
#[derive(Debug, Clone,
|
|
132
|
+
#[derive(Debug, Clone, bon::Builder)]
|
|
135
133
|
pub struct TestServerConfig {
|
|
136
134
|
/// Required path to executable or download info.
|
|
137
135
|
pub exe: EphemeralExe,
|
|
138
136
|
/// Port to use or obtains a free one if none given.
|
|
139
|
-
#[builder(default)]
|
|
140
137
|
pub port: Option<u16>,
|
|
141
138
|
/// Additional arguments to the test server.
|
|
142
139
|
#[builder(default)]
|
|
@@ -221,19 +218,19 @@ impl EphemeralServer {
|
|
|
221
218
|
child,
|
|
222
219
|
});
|
|
223
220
|
|
|
224
|
-
|
|
225
|
-
// TODO(cretz): Some other way, e.g. via stdout, to know whether the
|
|
226
|
-
// server is up?
|
|
227
|
-
let client_options = ClientOptions::builder()
|
|
221
|
+
let connection_options = ConnectionOptions::new(Url::parse(&target_url)?)
|
|
228
222
|
.identity("online_checker".to_owned())
|
|
229
|
-
.target_url(Url::parse(&target_url)?)
|
|
230
223
|
.client_name("online-checker".to_owned())
|
|
231
224
|
.client_version("0.1.0".to_owned())
|
|
232
225
|
.build();
|
|
226
|
+
|
|
227
|
+
// Try to connect every 100ms for 5s
|
|
228
|
+
// TODO(cretz): Some other way, e.g. via stdout, to know whether the
|
|
229
|
+
// server is up?
|
|
233
230
|
let mut last_error = None;
|
|
234
231
|
for _ in 0..50 {
|
|
235
232
|
sleep(Duration::from_millis(100)).await;
|
|
236
|
-
let connect_res =
|
|
233
|
+
let connect_res = Connection::connect(connection_options.clone()).await;
|
|
237
234
|
if let Err(err) = connect_res {
|
|
238
235
|
last_error = Some(err);
|
|
239
236
|
} else {
|
|
@@ -5,27 +5,37 @@
|
|
|
5
5
|
//! We can use `clap` if this needs more arguments / other stuff later on.
|
|
6
6
|
|
|
7
7
|
use prost::Message;
|
|
8
|
-
use temporalio_client::{
|
|
8
|
+
use temporalio_client::{
|
|
9
|
+
Client, ClientOptions, Connection, ConnectionOptions, NamespacedClient, WorkflowExecutionInfo,
|
|
10
|
+
WorkflowFetchHistoryOptions,
|
|
11
|
+
};
|
|
12
|
+
use temporalio_common::protos::temporal::api::history::v1::History;
|
|
9
13
|
use url::Url;
|
|
10
14
|
|
|
11
15
|
#[tokio::main]
|
|
12
16
|
async fn main() -> Result<(), anyhow::Error> {
|
|
13
|
-
let
|
|
14
|
-
let copts = ClientOptions::builder()
|
|
17
|
+
let copts = ConnectionOptions::new(Url::try_from("http://localhost:7233").unwrap())
|
|
15
18
|
.client_name("histfetch")
|
|
16
19
|
.client_version("0.0")
|
|
17
|
-
.target_url(url)
|
|
18
20
|
.build();
|
|
19
|
-
let
|
|
21
|
+
let connection = Connection::connect(copts).await?;
|
|
22
|
+
let client = Client::new(connection, ClientOptions::new("default").build())?;
|
|
20
23
|
let wf_id = std::env::args()
|
|
21
24
|
.nth(1)
|
|
22
25
|
.expect("must provide workflow id as only argument");
|
|
23
|
-
let run_id = std::env::args().nth(2);
|
|
24
|
-
let
|
|
25
|
-
.
|
|
26
|
+
let run_id = std::env::args().nth(2).filter(|s| !s.is_empty());
|
|
27
|
+
let handle = WorkflowExecutionInfo {
|
|
28
|
+
namespace: client.namespace(),
|
|
29
|
+
workflow_id: wf_id.clone(),
|
|
30
|
+
run_id,
|
|
31
|
+
first_execution_run_id: None,
|
|
32
|
+
}
|
|
33
|
+
.bind_untyped(client);
|
|
34
|
+
let events = handle
|
|
35
|
+
.fetch_history(WorkflowFetchHistoryOptions::default())
|
|
26
36
|
.await?
|
|
27
|
-
.
|
|
28
|
-
|
|
37
|
+
.into_events();
|
|
38
|
+
let hist = History { events };
|
|
29
39
|
// Serialize history to file
|
|
30
40
|
let byteified = hist.encode_to_vec();
|
|
31
41
|
tokio::fs::write(format!("{wf_id}_history.bin"), &byteified).await?;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
#![allow(clippy::upper_case_acronyms)]
|
|
3
3
|
|
|
4
4
|
//! This crate provides a basis for creating new Temporal SDKs without completely starting from
|
|
5
|
-
//! scratch
|
|
5
|
+
//! scratch. APIs provided by this crate are not considered stable and may break at any time.
|
|
6
|
+
//!
|
|
7
|
+
//! If you are looking for the Temporal Rust SDK, please use `temporalio-sdk`.
|
|
6
8
|
|
|
7
9
|
#[cfg(test)]
|
|
8
10
|
#[macro_use]
|
|
@@ -32,41 +34,38 @@ mod core_tests;
|
|
|
32
34
|
#[macro_use]
|
|
33
35
|
pub mod test_help;
|
|
34
36
|
|
|
35
|
-
pub
|
|
36
|
-
|
|
37
|
-
pub use pollers::{
|
|
38
|
-
Client, ClientOptions, ClientTlsOptions, RetryClient, RetryOptions, TlsOptions,
|
|
39
|
-
WorkflowClientTrait,
|
|
37
|
+
pub use crate::worker::client::{
|
|
38
|
+
PollActivityOptions, PollOptions, PollWorkflowOptions, WorkerClient, WorkflowTaskCompletion,
|
|
40
39
|
};
|
|
40
|
+
pub use pollers::{Client, ClientOptions, ClientTlsOptions, RetryOptions, TlsOptions};
|
|
41
41
|
pub use temporalio_common::protos::TaskToken;
|
|
42
42
|
pub use url::Url;
|
|
43
43
|
pub use worker::{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
ActivitySlotKind, CompleteActivityError, CompleteNexusError, CompleteWfError,
|
|
45
|
+
FixedSizeSlotSupplier, LocalActivitySlotKind, NexusSlotKind, PollError, PollerBehavior,
|
|
46
|
+
ResourceBasedSlotsOptions, ResourceBasedSlotsOptionsBuilder, ResourceBasedTuner,
|
|
47
|
+
ResourceSlotOptions, SlotInfo, SlotInfoTrait, SlotKind, SlotKindType, SlotMarkUsedContext,
|
|
48
|
+
SlotReleaseContext, SlotReservationContext, SlotSupplier, SlotSupplierOptions,
|
|
49
|
+
SlotSupplierPermit, TunerBuilder, TunerHolder, TunerHolderOptions, TunerHolderOptionsBuilder,
|
|
50
|
+
Worker, WorkerConfig, WorkerConfigBuilder, WorkerTuner, WorkerValidationError,
|
|
51
|
+
WorkerVersioningStrategy, WorkflowErrorType, WorkflowSlotKind,
|
|
47
52
|
};
|
|
48
53
|
|
|
49
|
-
/// Expose [WorkerClient] symbols
|
|
50
|
-
pub use crate::worker::client::{
|
|
51
|
-
PollActivityOptions, PollOptions, PollWorkflowOptions, WorkerClient, WorkflowTaskCompletion,
|
|
52
|
-
};
|
|
53
54
|
use crate::{
|
|
54
55
|
replay::{HistoryForReplay, ReplayWorkerInput},
|
|
55
|
-
telemetry::
|
|
56
|
-
TelemetryInstance, metrics::MetricsContext, remove_trace_subscriber_for_current_thread,
|
|
57
|
-
set_trace_subscriber_for_current_thread, telemetry_init,
|
|
58
|
-
},
|
|
56
|
+
telemetry::metrics::MetricsContext,
|
|
59
57
|
worker::client::WorkerClientBag,
|
|
60
58
|
};
|
|
61
59
|
use anyhow::bail;
|
|
62
60
|
use futures_util::Stream;
|
|
63
61
|
use std::{sync::Arc, time::Duration};
|
|
64
|
-
use temporalio_client::{
|
|
62
|
+
use temporalio_client::{Connection, SharedReplaceableClient};
|
|
65
63
|
use temporalio_common::{
|
|
66
|
-
Worker as WorkerTrait,
|
|
67
|
-
errors::{CompleteActivityError, PollError},
|
|
68
64
|
protos::coresdk::ActivityHeartbeat,
|
|
69
|
-
telemetry::
|
|
65
|
+
telemetry::{
|
|
66
|
+
TelemetryInstance, TelemetryOptions, remove_trace_subscriber_for_current_thread,
|
|
67
|
+
set_trace_subscriber_for_current_thread, telemetry_init,
|
|
68
|
+
},
|
|
70
69
|
};
|
|
71
70
|
|
|
72
71
|
/// Initialize a worker bound to a task queue.
|
|
@@ -75,44 +74,37 @@ use temporalio_common::{
|
|
|
75
74
|
/// After the worker is initialized, you should use [CoreRuntime::tokio_handle] to run the worker's
|
|
76
75
|
/// async functions.
|
|
77
76
|
///
|
|
78
|
-
/// Lang implementations
|
|
79
|
-
///
|
|
80
|
-
///
|
|
81
|
-
|
|
82
|
-
/// [ClientOptions::connect_no_namespace], not [ClientOptions::connect].
|
|
83
|
-
pub fn init_worker<CT>(
|
|
77
|
+
/// Lang implementations must pass in a [Client] When they do so, this function will always
|
|
78
|
+
/// overwrite the client retry configuration, force the client to use the namespace defined in the
|
|
79
|
+
/// worker config, and set the client identity appropriately.
|
|
80
|
+
pub fn init_worker(
|
|
84
81
|
runtime: &CoreRuntime,
|
|
85
82
|
worker_config: WorkerConfig,
|
|
86
|
-
|
|
87
|
-
) -> Result<Worker, anyhow::Error>
|
|
88
|
-
where
|
|
89
|
-
CT: Into<sealed::AnyClient>,
|
|
90
|
-
{
|
|
83
|
+
mut connection: Connection,
|
|
84
|
+
) -> Result<Worker, anyhow::Error> {
|
|
91
85
|
let namespace = worker_config.namespace.clone();
|
|
92
86
|
if namespace.is_empty() {
|
|
93
87
|
bail!("Worker namespace cannot be empty");
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
client,
|
|
101
|
-
)),
|
|
102
|
-
RetryOptions::default(),
|
|
90
|
+
*connection.retry_options_mut() = RetryOptions::default();
|
|
91
|
+
init_worker_client(
|
|
92
|
+
&mut connection,
|
|
93
|
+
worker_config.client_identity_override.clone(),
|
|
103
94
|
);
|
|
104
|
-
let
|
|
105
|
-
let
|
|
106
|
-
|
|
95
|
+
let client = SharedReplaceableClient::new(connection);
|
|
96
|
+
let client_ident = client.inner_cow().identity().to_owned();
|
|
107
97
|
if client_ident.is_empty() {
|
|
108
98
|
bail!("Client identity cannot be empty. Either lang or user should be setting this value");
|
|
109
99
|
}
|
|
100
|
+
let sticky_q = sticky_q_name_for_worker(&client_ident, worker_config.max_cached_workflows);
|
|
110
101
|
|
|
102
|
+
let worker_instance_key = uuid::Uuid::new_v4();
|
|
111
103
|
let client_bag = Arc::new(WorkerClientBag::new(
|
|
112
104
|
client,
|
|
113
105
|
namespace.clone(),
|
|
114
|
-
client_ident.clone(),
|
|
115
106
|
worker_config.versioning_strategy.clone(),
|
|
107
|
+
worker_instance_key,
|
|
116
108
|
));
|
|
117
109
|
|
|
118
110
|
Worker::new(
|
|
@@ -141,19 +133,13 @@ where
|
|
|
141
133
|
rwi.into_core_worker()
|
|
142
134
|
}
|
|
143
135
|
|
|
144
|
-
pub(crate) fn init_worker_client
|
|
145
|
-
|
|
136
|
+
pub(crate) fn init_worker_client(
|
|
137
|
+
connection: &mut Connection,
|
|
146
138
|
client_identity_override: Option<String>,
|
|
147
|
-
|
|
148
|
-
) -> Client
|
|
149
|
-
where
|
|
150
|
-
CT: Into<sealed::AnyClient>,
|
|
151
|
-
{
|
|
152
|
-
let mut client = Client::new(*client.into().into_inner(), namespace.clone());
|
|
139
|
+
) {
|
|
153
140
|
if let Some(ref id_override) = client_identity_override {
|
|
154
|
-
|
|
141
|
+
connection.identity_mut().clone_from(id_override);
|
|
155
142
|
}
|
|
156
|
-
client
|
|
157
143
|
}
|
|
158
144
|
|
|
159
145
|
/// Creates a unique sticky queue name for a worker, iff the config allows for 1 or more cached
|
|
@@ -173,63 +159,6 @@ pub(crate) fn sticky_q_name_for_worker(
|
|
|
173
159
|
}
|
|
174
160
|
}
|
|
175
161
|
|
|
176
|
-
mod sealed {
|
|
177
|
-
use super::*;
|
|
178
|
-
use temporalio_client::{SharedReplaceableClient, TemporalServiceClient};
|
|
179
|
-
|
|
180
|
-
/// Allows passing different kinds of clients into things that want to be flexible. Motivating
|
|
181
|
-
/// use-case was worker initialization.
|
|
182
|
-
///
|
|
183
|
-
/// Needs to exist in this crate to avoid blanket impl conflicts.
|
|
184
|
-
pub struct AnyClient {
|
|
185
|
-
pub(crate) inner: Box<ConfiguredClient<TemporalServiceClient>>,
|
|
186
|
-
}
|
|
187
|
-
impl AnyClient {
|
|
188
|
-
pub(crate) fn into_inner(self) -> Box<ConfiguredClient<TemporalServiceClient>> {
|
|
189
|
-
self.inner
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
impl From<ConfiguredClient<TemporalServiceClient>> for AnyClient {
|
|
194
|
-
fn from(c: ConfiguredClient<TemporalServiceClient>) -> Self {
|
|
195
|
-
Self { inner: Box::new(c) }
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
impl From<Client> for AnyClient {
|
|
200
|
-
fn from(c: Client) -> Self {
|
|
201
|
-
c.into_inner().into()
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
impl<T> From<RetryClient<T>> for AnyClient
|
|
206
|
-
where
|
|
207
|
-
T: Into<AnyClient>,
|
|
208
|
-
{
|
|
209
|
-
fn from(c: RetryClient<T>) -> Self {
|
|
210
|
-
c.into_inner().into()
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
impl<T> From<SharedReplaceableClient<T>> for AnyClient
|
|
215
|
-
where
|
|
216
|
-
T: Into<AnyClient> + Clone + Send + Sync,
|
|
217
|
-
{
|
|
218
|
-
fn from(c: SharedReplaceableClient<T>) -> Self {
|
|
219
|
-
c.inner_clone().into()
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
impl<T> From<Arc<T>> for AnyClient
|
|
224
|
-
where
|
|
225
|
-
T: Into<AnyClient> + Clone,
|
|
226
|
-
{
|
|
227
|
-
fn from(c: Arc<T>) -> Self {
|
|
228
|
-
Arc::unwrap_or_clone(c).into()
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
162
|
/// Holds shared state/components needed to back instances of workers and clients. More than one
|
|
234
163
|
/// may be instantiated, but typically only one is needed. More than one runtime instance may be
|
|
235
164
|
/// useful if multiple different telemetry settings are required.
|
|
@@ -240,9 +169,10 @@ pub struct CoreRuntime {
|
|
|
240
169
|
heartbeat_interval: Option<Duration>,
|
|
241
170
|
}
|
|
242
171
|
|
|
243
|
-
/// Holds telemetry options, as well as worker heartbeat_interval. Construct with
|
|
244
|
-
|
|
245
|
-
#[
|
|
172
|
+
/// Holds telemetry options, as well as worker heartbeat_interval. Construct with
|
|
173
|
+
/// [RuntimeOptions::builder]
|
|
174
|
+
#[derive(Default, bon::Builder)]
|
|
175
|
+
#[builder(finish_fn(vis = "", name = build_internal))]
|
|
246
176
|
#[non_exhaustive]
|
|
247
177
|
pub struct RuntimeOptions {
|
|
248
178
|
/// Telemetry configuration options.
|
|
@@ -252,21 +182,28 @@ pub struct RuntimeOptions {
|
|
|
252
182
|
/// workers created using this runtime.
|
|
253
183
|
///
|
|
254
184
|
/// Interval must be between 1s and 60s, inclusive.
|
|
255
|
-
#[builder(default =
|
|
185
|
+
#[builder(required, default = Some(Duration::from_secs(60)))]
|
|
256
186
|
heartbeat_interval: Option<Duration>,
|
|
257
187
|
}
|
|
258
188
|
|
|
259
|
-
impl RuntimeOptionsBuilder {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
189
|
+
impl<S: runtime_options_builder::State> RuntimeOptionsBuilder<S> {
|
|
190
|
+
/// Builds the RuntimeOptions
|
|
191
|
+
///
|
|
192
|
+
/// # Errors
|
|
193
|
+
/// Returns an error if heartbeat_interval is set but not between 1s and 60s inclusive.
|
|
194
|
+
pub fn build(self) -> Result<RuntimeOptions, String> {
|
|
195
|
+
let options = self.build_internal();
|
|
263
196
|
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
197
|
+
if let Some(interval) = options.heartbeat_interval
|
|
198
|
+
&& (interval < Duration::from_secs(1) || interval > Duration::from_secs(60))
|
|
199
|
+
{
|
|
200
|
+
return Err(format!(
|
|
201
|
+
"heartbeat_interval ({interval:?}) must be between 1s and 60s",
|
|
202
|
+
));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
Ok(options)
|
|
267
206
|
}
|
|
268
|
-
|
|
269
|
-
Ok(())
|
|
270
207
|
}
|
|
271
208
|
}
|
|
272
209
|
|
|
@@ -3,23 +3,18 @@ mod poll_buffer;
|
|
|
3
3
|
pub(crate) use poll_buffer::{
|
|
4
4
|
ActivityTaskOptions, LongPollBuffer, WorkflowTaskOptions, WorkflowTaskPoller,
|
|
5
5
|
};
|
|
6
|
-
pub use temporalio_client::{
|
|
7
|
-
Client, ClientOptions, ClientTlsOptions, RetryClient, RetryOptions, TlsOptions,
|
|
8
|
-
WorkflowClientTrait,
|
|
9
|
-
};
|
|
6
|
+
pub use temporalio_client::{Client, ClientOptions, ClientTlsOptions, RetryOptions, TlsOptions};
|
|
10
7
|
|
|
11
8
|
use crate::{
|
|
12
9
|
abstractions::{OwnedMeteredSemPermit, TrackedOwnedMeteredSemPermit},
|
|
13
10
|
telemetry::metrics::MetricsContext,
|
|
11
|
+
worker::{ActivitySlotKind, NexusSlotKind, SlotKind, WorkflowSlotKind},
|
|
14
12
|
};
|
|
15
13
|
use anyhow::{anyhow, bail};
|
|
16
14
|
use futures_util::{Stream, stream};
|
|
17
15
|
use std::{fmt::Debug, marker::PhantomData};
|
|
18
|
-
use temporalio_common::{
|
|
19
|
-
|
|
20
|
-
PollActivityTaskQueueResponse, PollNexusTaskQueueResponse, PollWorkflowTaskQueueResponse,
|
|
21
|
-
},
|
|
22
|
-
worker::{ActivitySlotKind, NexusSlotKind, SlotKind, WorkflowSlotKind},
|
|
16
|
+
use temporalio_common::protos::temporal::api::workflowservice::v1::{
|
|
17
|
+
PollActivityTaskQueueResponse, PollNexusTaskQueueResponse, PollWorkflowTaskQueueResponse,
|
|
23
18
|
};
|
|
24
19
|
use tokio::select;
|
|
25
20
|
use tokio_util::sync::CancellationToken;
|