@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
|
-
ByteArrayRef,
|
|
2
|
+
ByteArrayRef, ByteArrayRefArray,
|
|
3
3
|
client::{
|
|
4
4
|
ClientGrpcOverrideRequest, ClientGrpcOverrideResponse, RpcService,
|
|
5
5
|
temporal_core_client_grpc_override_request_headers,
|
|
@@ -9,12 +9,16 @@ use crate::{
|
|
|
9
9
|
temporal_core_client_grpc_override_request_service,
|
|
10
10
|
},
|
|
11
11
|
tests::utils::{
|
|
12
|
-
OwnedRpcCallOptions, RpcCallError,
|
|
12
|
+
OwnedRpcCallOptions, RpcCallError, default_connection_options, default_server_config,
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
|
+
use base64::{Engine, engine::general_purpose::STANDARD_NO_PAD};
|
|
15
16
|
use context::Context;
|
|
16
17
|
use prost::Message;
|
|
17
|
-
use std::
|
|
18
|
+
use std::{
|
|
19
|
+
collections::HashMap,
|
|
20
|
+
sync::{Arc, LazyLock, Mutex},
|
|
21
|
+
};
|
|
18
22
|
use temporalio_common::protos::temporal::api::{
|
|
19
23
|
failure::v1::Failure,
|
|
20
24
|
workflowservice::v1::{
|
|
@@ -34,7 +38,7 @@ fn test_get_system_info() {
|
|
|
34
38
|
.start_dev_server(Box::new(default_server_config()))
|
|
35
39
|
.unwrap();
|
|
36
40
|
context
|
|
37
|
-
.client_connect(Box::new(
|
|
41
|
+
.client_connect(Box::new(default_connection_options(
|
|
38
42
|
&context.ephemeral_server_target().unwrap().unwrap(),
|
|
39
43
|
)))
|
|
40
44
|
.unwrap();
|
|
@@ -46,6 +50,7 @@ fn test_get_system_info() {
|
|
|
46
50
|
req: GetSystemInfoRequest {}.encode_to_vec(),
|
|
47
51
|
retry: false,
|
|
48
52
|
metadata: None,
|
|
53
|
+
binary_metadata: None,
|
|
49
54
|
timeout_millis: 0,
|
|
50
55
|
cancellation_token: None,
|
|
51
56
|
}))
|
|
@@ -62,6 +67,7 @@ fn rpc_call_exists(context: &Arc<Context>, service: RpcService, rpc: &str) -> bo
|
|
|
62
67
|
req: Vec::new(),
|
|
63
68
|
retry: false,
|
|
64
69
|
metadata: None,
|
|
70
|
+
binary_metadata: None,
|
|
65
71
|
timeout_millis: 0,
|
|
66
72
|
cancellation_token: None,
|
|
67
73
|
}));
|
|
@@ -82,7 +88,7 @@ fn test_missing_rpc_call_has_expected_error_message() {
|
|
|
82
88
|
.start_dev_server(Box::new(default_server_config()))
|
|
83
89
|
.unwrap();
|
|
84
90
|
context
|
|
85
|
-
.client_connect(Box::new(
|
|
91
|
+
.client_connect(Box::new(default_connection_options(
|
|
86
92
|
&context.ephemeral_server_target().unwrap().unwrap(),
|
|
87
93
|
)))
|
|
88
94
|
.unwrap();
|
|
@@ -146,7 +152,7 @@ fn test_all_rpc_calls_exist() {
|
|
|
146
152
|
.start_dev_server(Box::new(default_server_config()))
|
|
147
153
|
.unwrap();
|
|
148
154
|
context
|
|
149
|
-
.client_connect(Box::new(
|
|
155
|
+
.client_connect(Box::new(default_connection_options(
|
|
150
156
|
&context.ephemeral_server_target().unwrap().unwrap(),
|
|
151
157
|
)))
|
|
152
158
|
.unwrap();
|
|
@@ -215,9 +221,8 @@ unsafe extern "C" fn callback_override(
|
|
|
215
221
|
let mut calls = CALLBACK_OVERRIDE_CALLS.lock().unwrap();
|
|
216
222
|
|
|
217
223
|
// Simple header check to confirm headers are working
|
|
218
|
-
let headers =
|
|
219
|
-
|
|
220
|
-
assert!(headers.get("content-type").unwrap().as_str() == "application/grpc");
|
|
224
|
+
let headers = temporal_core_client_grpc_override_request_headers(req).to_vec_map_on_newlines();
|
|
225
|
+
assert_ascii_header_value(&headers, "content-type", "application/grpc");
|
|
221
226
|
|
|
222
227
|
// Confirm user data is as we expect
|
|
223
228
|
let user_data: &String = unsafe { &*(user_data as *const String) };
|
|
@@ -265,14 +270,14 @@ unsafe extern "C" fn callback_override(
|
|
|
265
270
|
let resp = match &resp_raw {
|
|
266
271
|
Ok(bytes) => ClientGrpcOverrideResponse {
|
|
267
272
|
status_code: 0,
|
|
268
|
-
headers:
|
|
273
|
+
headers: ByteArrayRefArray::empty(),
|
|
269
274
|
success_proto: bytes.as_slice().into(),
|
|
270
275
|
fail_message: ByteArrayRef::empty(),
|
|
271
276
|
fail_details: ByteArrayRef::empty(),
|
|
272
277
|
},
|
|
273
278
|
Err(err) => ClientGrpcOverrideResponse {
|
|
274
279
|
status_code: tonic::Code::Internal.into(),
|
|
275
|
-
headers:
|
|
280
|
+
headers: ByteArrayRefArray::empty(),
|
|
276
281
|
success_proto: ByteArrayRef::empty(),
|
|
277
282
|
fail_message: err.message.as_str().into(),
|
|
278
283
|
fail_details: if let Some(details) = &err.details {
|
|
@@ -294,7 +299,7 @@ fn test_simple_callback_override() {
|
|
|
294
299
|
// Create client which will invoke GetSystemInfo
|
|
295
300
|
context
|
|
296
301
|
.client_connect_with_override(
|
|
297
|
-
Box::new(
|
|
302
|
+
Box::new(default_connection_options("127.0.0.1:4567")),
|
|
298
303
|
Some(callback_override),
|
|
299
304
|
&mut user_data as *mut String as *mut libc::c_void,
|
|
300
305
|
)
|
|
@@ -312,6 +317,7 @@ fn test_simple_callback_override() {
|
|
|
312
317
|
.encode_to_vec(),
|
|
313
318
|
retry: false,
|
|
314
319
|
metadata: None,
|
|
320
|
+
binary_metadata: None,
|
|
315
321
|
timeout_millis: 0,
|
|
316
322
|
cancellation_token: None,
|
|
317
323
|
}))
|
|
@@ -330,6 +336,7 @@ fn test_simple_callback_override() {
|
|
|
330
336
|
req: QueryWorkflowRequest::default().encode_to_vec(),
|
|
331
337
|
retry: false,
|
|
332
338
|
metadata: None,
|
|
339
|
+
binary_metadata: None,
|
|
333
340
|
timeout_millis: 0,
|
|
334
341
|
cancellation_token: None,
|
|
335
342
|
}))
|
|
@@ -356,3 +363,92 @@ fn test_simple_callback_override() {
|
|
|
356
363
|
);
|
|
357
364
|
});
|
|
358
365
|
}
|
|
366
|
+
|
|
367
|
+
unsafe extern "C" fn headers_callback_override(
|
|
368
|
+
req: *mut ClientGrpcOverrideRequest,
|
|
369
|
+
_user_data: *mut libc::c_void,
|
|
370
|
+
) {
|
|
371
|
+
// Check headers
|
|
372
|
+
let headers = temporal_core_client_grpc_override_request_headers(req).to_vec_map_on_newlines();
|
|
373
|
+
assert_ascii_header_value(&headers, "content-type", "application/grpc");
|
|
374
|
+
assert_ascii_header_value(&headers, "x-test", "client-ascii");
|
|
375
|
+
assert_binary_header_value(&headers, "x-test-bin", b"client-binary");
|
|
376
|
+
|
|
377
|
+
// Return minimal response
|
|
378
|
+
let resp_raw: Vec<u8> = GetSystemInfoResponse::default().encode_to_vec();
|
|
379
|
+
let resp = ClientGrpcOverrideResponse {
|
|
380
|
+
status_code: 0,
|
|
381
|
+
headers: ByteArrayRefArray::empty(),
|
|
382
|
+
success_proto: resp_raw.as_slice().into(),
|
|
383
|
+
fail_message: ByteArrayRef::empty(),
|
|
384
|
+
fail_details: ByteArrayRef::empty(),
|
|
385
|
+
};
|
|
386
|
+
temporal_core_client_grpc_override_request_respond(req, resp);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
#[test]
|
|
390
|
+
fn test_callback_override_with_headers() {
|
|
391
|
+
Context::with(|context| {
|
|
392
|
+
context.runtime_new().unwrap();
|
|
393
|
+
|
|
394
|
+
// Prepare client options with headers
|
|
395
|
+
let mut client_options = default_connection_options("127.0.0.1:4567");
|
|
396
|
+
client_options.headers = Some(HashMap::from([(
|
|
397
|
+
"x-test".to_owned(),
|
|
398
|
+
"client-ascii".to_owned(),
|
|
399
|
+
)]));
|
|
400
|
+
client_options.binary_headers = Some(HashMap::from([(
|
|
401
|
+
"x-test-bin".to_owned(),
|
|
402
|
+
b"client-binary".to_vec(),
|
|
403
|
+
)]));
|
|
404
|
+
|
|
405
|
+
// Create client which will invoke GetSystemInfo
|
|
406
|
+
context
|
|
407
|
+
.client_connect_with_override(
|
|
408
|
+
Box::new(client_options),
|
|
409
|
+
Some(headers_callback_override),
|
|
410
|
+
std::ptr::null_mut(),
|
|
411
|
+
)
|
|
412
|
+
.unwrap();
|
|
413
|
+
|
|
414
|
+
// Invoke start workflow
|
|
415
|
+
let _ = context
|
|
416
|
+
.rpc_call(Box::new(OwnedRpcCallOptions {
|
|
417
|
+
service: RpcService::Workflow,
|
|
418
|
+
rpc: "StartWorkflowExecution".into(),
|
|
419
|
+
req: StartWorkflowExecutionRequest {
|
|
420
|
+
workflow_id: "my-workflow-id".into(),
|
|
421
|
+
..Default::default()
|
|
422
|
+
}
|
|
423
|
+
.encode_to_vec(),
|
|
424
|
+
retry: false,
|
|
425
|
+
metadata: None,
|
|
426
|
+
binary_metadata: None,
|
|
427
|
+
timeout_millis: 0,
|
|
428
|
+
cancellation_token: None,
|
|
429
|
+
}))
|
|
430
|
+
.unwrap();
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
fn assert_ascii_header_value(headers: &HashMap<String, Vec<u8>>, key: &str, expected_value: &str) {
|
|
435
|
+
let value = headers.get(key);
|
|
436
|
+
assert!(value.is_some());
|
|
437
|
+
assert_eq!(
|
|
438
|
+
expected_value,
|
|
439
|
+
String::from_utf8(value.unwrap().to_vec()).unwrap(),
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
fn assert_binary_header_value(
|
|
444
|
+
headers: &HashMap<String, Vec<u8>>,
|
|
445
|
+
key: &str,
|
|
446
|
+
expected_value: &[u8],
|
|
447
|
+
) {
|
|
448
|
+
let value = headers.get(key);
|
|
449
|
+
assert!(value.is_some());
|
|
450
|
+
let decode_result = STANDARD_NO_PAD.decode(value.unwrap());
|
|
451
|
+
assert!(decode_result.is_ok());
|
|
452
|
+
let decoded = decode_result.ok().unwrap();
|
|
453
|
+
assert_eq!(expected_value, decoded);
|
|
454
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
ByteArray, CancellationToken,
|
|
3
|
-
client::RpcService,
|
|
3
|
+
client::{GrpcMetadataHolder, RpcService},
|
|
4
4
|
runtime::{Runtime, temporal_core_byte_array_free},
|
|
5
5
|
};
|
|
6
|
-
use std::
|
|
7
|
-
use temporalio_client::
|
|
8
|
-
use temporalio_sdk_core::ephemeral_server::{
|
|
9
|
-
TemporalDevServerConfig, TemporalDevServerConfigBuilder, default_cached_download,
|
|
10
|
-
};
|
|
6
|
+
use std::ops::Deref;
|
|
7
|
+
use temporalio_client::ConnectionOptions;
|
|
8
|
+
use temporalio_sdk_core::ephemeral_server::{TemporalDevServerConfig, default_cached_download};
|
|
11
9
|
use url::Url;
|
|
12
10
|
|
|
13
11
|
pub fn byte_array_to_vec(runtime: *mut Runtime, byte_array: *const ByteArray) -> Option<Vec<u8>> {
|
|
@@ -31,15 +29,13 @@ pub fn pointer_or_null<T>(x: Option<impl Deref<Target = T>>) -> *const T {
|
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
pub fn default_server_config() -> TemporalDevServerConfig {
|
|
34
|
-
|
|
32
|
+
TemporalDevServerConfig::builder()
|
|
35
33
|
.exe(default_cached_download())
|
|
36
34
|
.build()
|
|
37
|
-
.unwrap()
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
pub fn
|
|
41
|
-
|
|
42
|
-
.target_url(Url::parse(&format!("http://{target}")).unwrap())
|
|
37
|
+
pub fn default_connection_options(target: &str) -> ConnectionOptions {
|
|
38
|
+
ConnectionOptions::new(Url::parse(&format!("http://{target}")).unwrap())
|
|
43
39
|
.client_name("core-c-bridge-tests".to_owned())
|
|
44
40
|
.client_version("0.1.0".to_owned())
|
|
45
41
|
.build()
|
|
@@ -50,7 +46,8 @@ pub struct OwnedRpcCallOptions {
|
|
|
50
46
|
pub rpc: String,
|
|
51
47
|
pub req: Vec<u8>,
|
|
52
48
|
pub retry: bool,
|
|
53
|
-
pub metadata: Option<
|
|
49
|
+
pub metadata: Option<GrpcMetadataHolder>,
|
|
50
|
+
pub binary_metadata: Option<GrpcMetadataHolder>,
|
|
54
51
|
pub timeout_millis: u32,
|
|
55
52
|
pub cancellation_token: Option<*mut CancellationToken>,
|
|
56
53
|
}
|
|
@@ -58,46 +55,6 @@ pub struct OwnedRpcCallOptions {
|
|
|
58
55
|
unsafe impl Send for OwnedRpcCallOptions {}
|
|
59
56
|
unsafe impl Sync for OwnedRpcCallOptions {}
|
|
60
57
|
|
|
61
|
-
#[derive(Clone, Debug)]
|
|
62
|
-
pub enum MetadataMap {
|
|
63
|
-
Deserialized(HashMap<String, String>),
|
|
64
|
-
Serialized(String),
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
impl From<HashMap<String, String>> for MetadataMap {
|
|
68
|
-
fn from(value: HashMap<String, String>) -> Self {
|
|
69
|
-
Self::Deserialized(value)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
#[allow(dead_code)]
|
|
74
|
-
impl MetadataMap {
|
|
75
|
-
pub fn serialize_from_map(map: &HashMap<String, String>) -> String {
|
|
76
|
-
map.iter().map(|(k, v)| format!("{k}\n{v}\n")).collect()
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
pub fn serialize(&self) -> String {
|
|
80
|
-
match self {
|
|
81
|
-
Self::Deserialized(map) => Self::serialize_from_map(map),
|
|
82
|
-
Self::Serialized(s) => s.clone(),
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
pub fn serialize_in_place(&mut self) {
|
|
87
|
-
if let Self::Deserialized(map) = self {
|
|
88
|
-
*self = Self::Serialized(Self::serialize_from_map(map));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
pub fn as_str(&mut self) -> &str {
|
|
93
|
-
self.serialize_in_place();
|
|
94
|
-
let Self::Serialized(s) = self else {
|
|
95
|
-
unreachable!();
|
|
96
|
-
};
|
|
97
|
-
s
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
58
|
#[derive(thiserror::Error, Debug)]
|
|
102
59
|
#[error("{message} (status code {status_code})")]
|
|
103
60
|
pub struct RpcCallError {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
ByteArray, ByteArrayRef, ByteArrayRefArray, UserDataHandle, client::
|
|
2
|
+
ByteArray, ByteArrayRef, ByteArrayRefArray, UserDataHandle, client::Connection,
|
|
3
|
+
runtime::Runtime,
|
|
3
4
|
};
|
|
4
5
|
use anyhow::{Context, bail};
|
|
5
6
|
use crossbeam_utils::atomic::AtomicCell;
|
|
@@ -10,23 +11,16 @@ use std::{
|
|
|
10
11
|
sync::Arc,
|
|
11
12
|
time::Duration,
|
|
12
13
|
};
|
|
13
|
-
use temporalio_common::{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
coresdk::{
|
|
18
|
-
ActivityHeartbeat, ActivityTaskCompletion, nexus::NexusTaskCompletion,
|
|
19
|
-
workflow_completion::WorkflowActivationCompletion,
|
|
20
|
-
},
|
|
21
|
-
temporal::api::history::v1::History,
|
|
22
|
-
},
|
|
23
|
-
worker::{
|
|
24
|
-
SlotInfoTrait, SlotKind, SlotMarkUsedContext, SlotReleaseContext, SlotReservationContext,
|
|
25
|
-
SlotSupplierPermit,
|
|
14
|
+
use temporalio_common::protos::{
|
|
15
|
+
coresdk::{
|
|
16
|
+
ActivityHeartbeat, ActivityTaskCompletion, nexus::NexusTaskCompletion,
|
|
17
|
+
workflow_completion::WorkflowActivationCompletion,
|
|
26
18
|
},
|
|
19
|
+
temporal::api::history::v1::History,
|
|
27
20
|
};
|
|
28
21
|
use temporalio_sdk_core::{
|
|
29
|
-
|
|
22
|
+
PollError, SlotInfoTrait, SlotKind, SlotMarkUsedContext, SlotReleaseContext,
|
|
23
|
+
SlotReservationContext, SlotSupplierPermit, WorkerConfig, WorkflowErrorType,
|
|
30
24
|
replay::{HistoryForReplay, ReplayWorkerInput},
|
|
31
25
|
};
|
|
32
26
|
use tokio::sync::{
|
|
@@ -97,18 +91,18 @@ pub struct PollerBehavior {
|
|
|
97
91
|
pub autoscaling: *const PollerBehaviorAutoscaling,
|
|
98
92
|
}
|
|
99
93
|
|
|
100
|
-
impl TryFrom<&PollerBehavior> for
|
|
94
|
+
impl TryFrom<&PollerBehavior> for temporalio_sdk_core::PollerBehavior {
|
|
101
95
|
type Error = anyhow::Error;
|
|
102
96
|
fn try_from(value: &PollerBehavior) -> Result<Self, Self::Error> {
|
|
103
97
|
if !value.simple_maximum.is_null() && !value.autoscaling.is_null() {
|
|
104
98
|
bail!("simple_maximum and autoscaling cannot both be non-null values");
|
|
105
99
|
}
|
|
106
100
|
if let Some(value) = unsafe { value.simple_maximum.as_ref() } {
|
|
107
|
-
return Ok(
|
|
101
|
+
return Ok(temporalio_sdk_core::PollerBehavior::SimpleMaximum(
|
|
108
102
|
value.simple_maximum,
|
|
109
103
|
));
|
|
110
104
|
} else if let Some(value) = unsafe { value.autoscaling.as_ref() } {
|
|
111
|
-
return Ok(
|
|
105
|
+
return Ok(temporalio_sdk_core::PollerBehavior::Autoscaling {
|
|
112
106
|
minimum: value.minimum,
|
|
113
107
|
maximum: value.maximum,
|
|
114
108
|
initial: value.initial,
|
|
@@ -237,7 +231,7 @@ pub struct CustomSlotSupplierCallbacks {
|
|
|
237
231
|
/// is arbitrary, but must be unique among live reservations as it's later used for [`mark_used`](Self::mark_used)
|
|
238
232
|
/// and [`release`](Self::release) callbacks.
|
|
239
233
|
pub try_reserve: CustomSlotSupplierTryReserveCallback,
|
|
240
|
-
/// Called after successful reservation to mark slot as used. See [`SlotSupplier`](
|
|
234
|
+
/// Called after successful reservation to mark slot as used. See [`SlotSupplier`](temporalio_sdk_core::SlotSupplier)
|
|
241
235
|
/// trait for details.
|
|
242
236
|
pub mark_used: CustomSlotSupplierMarkUsedCallback,
|
|
243
237
|
/// Called to free a previously reserved slot.
|
|
@@ -258,8 +252,7 @@ pub struct CustomSlotSupplierCallbacks {
|
|
|
258
252
|
impl CustomSlotSupplierCallbacksImpl {
|
|
259
253
|
fn into_ss<SK: SlotKind + Send + Sync + 'static>(
|
|
260
254
|
self,
|
|
261
|
-
) -> Arc<dyn
|
|
262
|
-
{
|
|
255
|
+
) -> Arc<dyn temporalio_sdk_core::SlotSupplier<SlotKind = SK> + Send + Sync + 'static> {
|
|
263
256
|
Arc::new(CustomSlotSupplier {
|
|
264
257
|
inner: self,
|
|
265
258
|
_pd: Default::default(),
|
|
@@ -376,9 +369,7 @@ impl<'a, SK: SlotKind + Send + Sync> Drop for CancelReserveGuard<'a, SK> {
|
|
|
376
369
|
}
|
|
377
370
|
|
|
378
371
|
#[async_trait::async_trait]
|
|
379
|
-
impl<SK: SlotKind + Send + Sync>
|
|
380
|
-
for CustomSlotSupplier<SK>
|
|
381
|
-
{
|
|
372
|
+
impl<SK: SlotKind + Send + Sync> temporalio_sdk_core::SlotSupplier for CustomSlotSupplier<SK> {
|
|
382
373
|
type SlotKind = SK;
|
|
383
374
|
|
|
384
375
|
async fn reserve_slot(&self, ctx: &dyn SlotReservationContext) -> SlotSupplierPermit {
|
|
@@ -467,16 +458,12 @@ impl<SK: SlotKind + Send + Sync> CustomSlotSupplier<SK> {
|
|
|
467
458
|
fn convert_reserve_ctx(ctx: &dyn SlotReservationContext) -> SlotReserveCtx {
|
|
468
459
|
SlotReserveCtx {
|
|
469
460
|
slot_type: match SK::kind() {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
temporalio_common::worker::SlotKindType::Activity => {
|
|
474
|
-
SlotKindType::ActivitySlotKindType
|
|
475
|
-
}
|
|
476
|
-
temporalio_common::worker::SlotKindType::LocalActivity => {
|
|
461
|
+
temporalio_sdk_core::SlotKindType::Workflow => SlotKindType::WorkflowSlotKindType,
|
|
462
|
+
temporalio_sdk_core::SlotKindType::Activity => SlotKindType::ActivitySlotKindType,
|
|
463
|
+
temporalio_sdk_core::SlotKindType::LocalActivity => {
|
|
477
464
|
SlotKindType::LocalActivitySlotKindType
|
|
478
465
|
}
|
|
479
|
-
|
|
466
|
+
temporalio_sdk_core::SlotKindType::Nexus => SlotKindType::NexusSlotKindType,
|
|
480
467
|
},
|
|
481
468
|
task_queue: ctx.task_queue().into(),
|
|
482
469
|
worker_identity: ctx.worker_identity().into(),
|
|
@@ -489,21 +476,19 @@ impl<SK: SlotKind + Send + Sync> CustomSlotSupplier<SK> {
|
|
|
489
476
|
}
|
|
490
477
|
}
|
|
491
478
|
|
|
492
|
-
fn convert_slot_info(info:
|
|
479
|
+
fn convert_slot_info(info: temporalio_sdk_core::SlotInfo) -> SlotInfo {
|
|
493
480
|
match info {
|
|
494
|
-
|
|
481
|
+
temporalio_sdk_core::SlotInfo::Workflow(w) => SlotInfo::WorkflowSlotInfo {
|
|
495
482
|
workflow_type: w.workflow_type.as_str().into(),
|
|
496
483
|
is_sticky: w.is_sticky,
|
|
497
484
|
},
|
|
498
|
-
|
|
485
|
+
temporalio_sdk_core::SlotInfo::Activity(a) => SlotInfo::ActivitySlotInfo {
|
|
499
486
|
activity_type: a.activity_type.as_str().into(),
|
|
500
487
|
},
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
temporalio_common::worker::SlotInfo::Nexus(n) => SlotInfo::NexusSlotInfo {
|
|
488
|
+
temporalio_sdk_core::SlotInfo::LocalActivity(a) => SlotInfo::LocalActivitySlotInfo {
|
|
489
|
+
activity_type: a.activity_type.as_str().into(),
|
|
490
|
+
},
|
|
491
|
+
temporalio_sdk_core::SlotInfo::Nexus(n) => SlotInfo::NexusSlotInfo {
|
|
507
492
|
operation: n.operation.as_str().into(),
|
|
508
493
|
service: n.service.as_str().into(),
|
|
509
494
|
},
|
|
@@ -563,43 +548,45 @@ macro_rules! enter_sync {
|
|
|
563
548
|
|
|
564
549
|
#[unsafe(no_mangle)]
|
|
565
550
|
pub extern "C" fn temporal_core_worker_new(
|
|
566
|
-
|
|
551
|
+
connection: *mut Connection,
|
|
567
552
|
options: *const WorkerOptions,
|
|
568
553
|
) -> WorkerOrFail {
|
|
569
|
-
let
|
|
570
|
-
enter_sync!(
|
|
554
|
+
let connection = unsafe { &mut *connection };
|
|
555
|
+
enter_sync!(connection.runtime);
|
|
571
556
|
let options = unsafe { &*options };
|
|
572
557
|
|
|
573
558
|
let (worker, fail) = match options.try_into() {
|
|
574
559
|
Err(err) => (
|
|
575
560
|
std::ptr::null_mut(),
|
|
576
|
-
|
|
561
|
+
connection
|
|
577
562
|
.runtime
|
|
578
563
|
.alloc_utf8(&format!("Invalid options: {err}"))
|
|
579
564
|
.into_raw()
|
|
580
565
|
.cast_const(),
|
|
581
566
|
),
|
|
582
|
-
Ok(config) =>
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
567
|
+
Ok(config) => {
|
|
568
|
+
match temporalio_sdk_core::init_worker(
|
|
569
|
+
&connection.runtime.core,
|
|
570
|
+
config,
|
|
571
|
+
connection.core.clone(),
|
|
572
|
+
) {
|
|
573
|
+
Err(err) => (
|
|
574
|
+
std::ptr::null_mut(),
|
|
575
|
+
connection
|
|
576
|
+
.runtime
|
|
577
|
+
.alloc_utf8(&format!("Worker start failed: {err}"))
|
|
578
|
+
.into_raw()
|
|
579
|
+
.cast_const(),
|
|
580
|
+
),
|
|
581
|
+
Ok(worker) => (
|
|
582
|
+
Box::into_raw(Box::new(Worker {
|
|
583
|
+
worker: Some(Arc::new(worker)),
|
|
584
|
+
runtime: connection.runtime.clone(),
|
|
585
|
+
})),
|
|
586
|
+
std::ptr::null(),
|
|
587
|
+
),
|
|
588
|
+
}
|
|
589
|
+
}
|
|
603
590
|
};
|
|
604
591
|
WorkerOrFail { worker, fail }
|
|
605
592
|
}
|
|
@@ -646,14 +633,14 @@ pub extern "C" fn temporal_core_worker_validate(
|
|
|
646
633
|
#[unsafe(no_mangle)]
|
|
647
634
|
pub extern "C" fn temporal_core_worker_replace_client(
|
|
648
635
|
worker: *mut Worker,
|
|
649
|
-
|
|
636
|
+
new_connection: *mut Connection,
|
|
650
637
|
) -> *const ByteArray {
|
|
651
638
|
let worker = unsafe { &*worker };
|
|
652
639
|
enter_sync!(worker.runtime);
|
|
653
640
|
let core_worker = worker.worker.as_ref().expect("missing worker").clone();
|
|
654
|
-
let client = unsafe { &*
|
|
641
|
+
let client = unsafe { &*new_connection };
|
|
655
642
|
|
|
656
|
-
match core_worker.replace_client(client.core.
|
|
643
|
+
match core_worker.replace_client(client.core.clone()) {
|
|
657
644
|
Ok(()) => std::ptr::null(),
|
|
658
645
|
Err(err) => worker
|
|
659
646
|
.runtime
|
|
@@ -1164,13 +1151,13 @@ impl TryFrom<&WorkerOptions> for temporalio_sdk_core::WorkerConfig {
|
|
|
1164
1151
|
|
|
1165
1152
|
fn try_from(opt: &WorkerOptions) -> anyhow::Result<Self> {
|
|
1166
1153
|
let converted_tuner: temporalio_sdk_core::TunerHolder = (&opt.tuner).try_into()?;
|
|
1167
|
-
|
|
1154
|
+
WorkerConfig::builder()
|
|
1168
1155
|
.namespace(opt.namespace.to_str())
|
|
1169
1156
|
.task_queue(opt.task_queue.to_str())
|
|
1170
1157
|
.versioning_strategy({
|
|
1171
1158
|
match &opt.versioning_strategy {
|
|
1172
1159
|
WorkerVersioningStrategy::None(n) => {
|
|
1173
|
-
|
|
1160
|
+
temporalio_sdk_core::WorkerVersioningStrategy::None {
|
|
1174
1161
|
build_id: n.build_id.to_string(),
|
|
1175
1162
|
}
|
|
1176
1163
|
}
|
|
@@ -1183,7 +1170,7 @@ impl TryFrom<&WorkerOptions> for temporalio_sdk_core::WorkerConfig {
|
|
|
1183
1170
|
dopts.default_versioning_behavior
|
|
1184
1171
|
)
|
|
1185
1172
|
};
|
|
1186
|
-
|
|
1173
|
+
temporalio_sdk_core::WorkerVersioningStrategy::WorkerDeploymentBased(
|
|
1187
1174
|
temporalio_common::worker::WorkerDeploymentOptions {
|
|
1188
1175
|
version: temporalio_common::worker::WorkerDeploymentVersion {
|
|
1189
1176
|
deployment_name: dopts.version.deployment_name.to_string(),
|
|
@@ -1195,13 +1182,13 @@ impl TryFrom<&WorkerOptions> for temporalio_sdk_core::WorkerConfig {
|
|
|
1195
1182
|
)
|
|
1196
1183
|
}
|
|
1197
1184
|
WorkerVersioningStrategy::LegacyBuildIdBased(l) => {
|
|
1198
|
-
|
|
1185
|
+
temporalio_sdk_core::WorkerVersioningStrategy::LegacyBuildIdBased {
|
|
1199
1186
|
build_id: l.build_id.to_string(),
|
|
1200
1187
|
}
|
|
1201
1188
|
}
|
|
1202
1189
|
}
|
|
1203
1190
|
})
|
|
1204
|
-
.
|
|
1191
|
+
.maybe_client_identity_override(opt.identity_override.to_option_string())
|
|
1205
1192
|
.max_cached_workflows(opt.max_cached_workflows as usize)
|
|
1206
1193
|
.tuner(Arc::new(converted_tuner))
|
|
1207
1194
|
.task_types(temporalio_common::worker::WorkerTaskTypes::from(
|
|
@@ -1216,12 +1203,12 @@ impl TryFrom<&WorkerOptions> for temporalio_sdk_core::WorkerConfig {
|
|
|
1216
1203
|
.default_heartbeat_throttle_interval(Duration::from_millis(
|
|
1217
1204
|
opt.default_heartbeat_throttle_interval_millis,
|
|
1218
1205
|
))
|
|
1219
|
-
.
|
|
1206
|
+
.maybe_max_worker_activities_per_second(if opt.max_activities_per_second == 0.0 {
|
|
1220
1207
|
None
|
|
1221
1208
|
} else {
|
|
1222
1209
|
Some(opt.max_activities_per_second)
|
|
1223
1210
|
})
|
|
1224
|
-
.
|
|
1211
|
+
.maybe_max_task_queue_activities_per_second(
|
|
1225
1212
|
if opt.max_task_queue_activities_per_second == 0.0 {
|
|
1226
1213
|
None
|
|
1227
1214
|
} else {
|
|
@@ -1232,14 +1219,14 @@ impl TryFrom<&WorkerOptions> for temporalio_sdk_core::WorkerConfig {
|
|
|
1232
1219
|
// auto-cancel-activity behavior or shutdown will not occur, so we
|
|
1233
1220
|
// always set it even if 0.
|
|
1234
1221
|
.graceful_shutdown_period(Duration::from_millis(opt.graceful_shutdown_period_millis))
|
|
1235
|
-
.workflow_task_poller_behavior(
|
|
1222
|
+
.workflow_task_poller_behavior(temporalio_sdk_core::PollerBehavior::try_from(
|
|
1236
1223
|
&opt.workflow_task_poller_behavior,
|
|
1237
1224
|
)?)
|
|
1238
1225
|
.nonsticky_to_sticky_poll_ratio(opt.nonsticky_to_sticky_poll_ratio)
|
|
1239
|
-
.activity_task_poller_behavior(
|
|
1226
|
+
.activity_task_poller_behavior(temporalio_sdk_core::PollerBehavior::try_from(
|
|
1240
1227
|
&opt.activity_task_poller_behavior,
|
|
1241
1228
|
)?)
|
|
1242
|
-
.nexus_task_poller_behavior(
|
|
1229
|
+
.nexus_task_poller_behavior(temporalio_sdk_core::PollerBehavior::try_from(
|
|
1243
1230
|
&opt.nexus_task_poller_behavior,
|
|
1244
1231
|
)?)
|
|
1245
1232
|
.workflow_failure_errors(if opt.nondeterminism_as_workflow_fail {
|
|
@@ -1324,23 +1311,19 @@ impl TryFrom<&TunerHolder> for temporalio_sdk_core::TunerHolder {
|
|
|
1324
1311
|
bail!("All resource-based slot suppliers must have the same ResourceBasedTunerOptions",);
|
|
1325
1312
|
}
|
|
1326
1313
|
|
|
1327
|
-
|
|
1328
|
-
if let Some(first) = first {
|
|
1329
|
-
options.resource_based_options(
|
|
1330
|
-
temporalio_sdk_core::ResourceBasedSlotsOptionsBuilder::default()
|
|
1331
|
-
.target_mem_usage(first.target_memory_usage)
|
|
1332
|
-
.target_cpu_usage(first.target_cpu_usage)
|
|
1333
|
-
.build()
|
|
1334
|
-
.expect("Building ResourceBasedSlotsOptions is infallible"),
|
|
1335
|
-
);
|
|
1336
|
-
};
|
|
1337
|
-
options
|
|
1314
|
+
temporalio_sdk_core::TunerHolderOptions::builder()
|
|
1338
1315
|
.workflow_slot_options(holder.workflow_slot_supplier.try_into()?)
|
|
1339
1316
|
.activity_slot_options(holder.activity_slot_supplier.try_into()?)
|
|
1340
1317
|
.local_activity_slot_options(holder.local_activity_slot_supplier.try_into()?)
|
|
1341
1318
|
.nexus_slot_options(holder.nexus_task_slot_supplier.try_into()?)
|
|
1319
|
+
.maybe_resource_based_options(first.map(|f| {
|
|
1320
|
+
temporalio_sdk_core::ResourceBasedSlotsOptions::builder()
|
|
1321
|
+
.target_mem_usage(f.target_memory_usage)
|
|
1322
|
+
.target_cpu_usage(f.target_cpu_usage)
|
|
1323
|
+
.build()
|
|
1324
|
+
}))
|
|
1342
1325
|
.build()
|
|
1343
|
-
.
|
|
1326
|
+
.map_err(|e| anyhow::anyhow!("Failed building tuner holder options: {}", e))?
|
|
1344
1327
|
.build_tuner_holder()
|
|
1345
1328
|
.context("Failed building tuner holder")
|
|
1346
1329
|
}
|
package/sdk-core/rustfmt.toml
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
imports_granularity="Crate"
|
|
1
|
+
imports_granularity="Crate"
|
|
2
|
+
format_code_in_doc_comments=true
|