@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
|
@@ -14,21 +14,20 @@ use std::{
|
|
|
14
14
|
time::Duration,
|
|
15
15
|
};
|
|
16
16
|
use temporalio_client::{
|
|
17
|
-
ClientKeepAliveOptions as CoreClientKeepAliveOptions,
|
|
18
|
-
|
|
19
|
-
OperatorService, RetryClient, RetryOptions, TemporalServiceClient, TestService,
|
|
20
|
-
TlsOptions as CoreTlsOptions, WorkflowService, callback_based, proxy::HttpConnectProxyOptions,
|
|
17
|
+
ClientKeepAliveOptions as CoreClientKeepAliveOptions, RetryOptions, callback_based,
|
|
18
|
+
grpc::{CloudService, HealthService, OperatorService, TestService, WorkflowService},
|
|
21
19
|
};
|
|
22
20
|
use tokio::sync::oneshot;
|
|
23
|
-
use tonic::metadata::MetadataKey;
|
|
21
|
+
use tonic::metadata::{MetadataKey, MetadataValue};
|
|
24
22
|
use url::Url;
|
|
25
23
|
|
|
26
24
|
#[repr(C)]
|
|
27
|
-
pub struct
|
|
25
|
+
pub struct ConnectionOptions {
|
|
28
26
|
pub target_url: ByteArrayRef,
|
|
29
27
|
pub client_name: ByteArrayRef,
|
|
30
28
|
pub client_version: ByteArrayRef,
|
|
31
29
|
pub metadata: MetadataRef,
|
|
30
|
+
pub binary_metadata: MetadataRef,
|
|
32
31
|
pub api_key: ByteArrayRef,
|
|
33
32
|
pub identity: ByteArrayRef,
|
|
34
33
|
pub tls_options: *const ClientTlsOptions,
|
|
@@ -79,21 +78,21 @@ pub struct ClientHttpConnectProxyOptions {
|
|
|
79
78
|
pub password: ByteArrayRef,
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
type
|
|
81
|
+
type CoreConnection = temporalio_client::Connection;
|
|
83
82
|
|
|
84
|
-
pub struct
|
|
83
|
+
pub struct Connection {
|
|
85
84
|
pub(crate) runtime: Runtime,
|
|
86
|
-
pub(crate) core:
|
|
85
|
+
pub(crate) core: CoreConnection,
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
// Expected to outlive all async calls that use it
|
|
90
|
-
unsafe impl Send for
|
|
91
|
-
unsafe impl Sync for
|
|
89
|
+
unsafe impl Send for Connection {}
|
|
90
|
+
unsafe impl Sync for Connection {}
|
|
92
91
|
|
|
93
92
|
/// If success or fail are not null, they must be manually freed when done.
|
|
94
93
|
pub type ClientConnectCallback = unsafe extern "C" fn(
|
|
95
94
|
user_data: *mut libc::c_void,
|
|
96
|
-
success: *mut
|
|
95
|
+
success: *mut Connection,
|
|
97
96
|
fail: *const ByteArray,
|
|
98
97
|
);
|
|
99
98
|
|
|
@@ -102,14 +101,14 @@ pub type ClientConnectCallback = unsafe extern "C" fn(
|
|
|
102
101
|
#[unsafe(no_mangle)]
|
|
103
102
|
pub extern "C" fn temporal_core_client_connect(
|
|
104
103
|
runtime: *mut Runtime,
|
|
105
|
-
options: *const
|
|
104
|
+
options: *const ConnectionOptions,
|
|
106
105
|
user_data: *mut libc::c_void,
|
|
107
106
|
callback: ClientConnectCallback,
|
|
108
107
|
) {
|
|
109
108
|
let runtime = unsafe { &mut *runtime };
|
|
110
109
|
// Convert opts
|
|
111
110
|
let options = unsafe { &*options };
|
|
112
|
-
let
|
|
111
|
+
let mut connection_options: temporalio_client::ConnectionOptions = match options.try_into() {
|
|
113
112
|
Ok(v) => v,
|
|
114
113
|
Err(err) => {
|
|
115
114
|
unsafe {
|
|
@@ -125,24 +124,22 @@ pub extern "C" fn temporal_core_client_connect(
|
|
|
125
124
|
}
|
|
126
125
|
};
|
|
127
126
|
// Create override if present
|
|
128
|
-
let
|
|
129
|
-
create_callback_based_grpc_service(
|
|
130
|
-
|
|
127
|
+
if let Some(cb) = options.grpc_override_callback {
|
|
128
|
+
connection_options.service_override = Some(create_callback_based_grpc_service(
|
|
129
|
+
runtime,
|
|
130
|
+
cb,
|
|
131
|
+
options.grpc_override_callback_user_data,
|
|
132
|
+
));
|
|
133
|
+
}
|
|
131
134
|
// Spawn async call
|
|
132
135
|
let user_data = UserDataHandle(user_data);
|
|
133
|
-
|
|
136
|
+
connection_options.metrics_meter = runtime.core.telemetry().get_metric_meter();
|
|
134
137
|
runtime.core.tokio_handle().spawn(async move {
|
|
135
|
-
match
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
service_override,
|
|
139
|
-
)
|
|
140
|
-
.await
|
|
141
|
-
{
|
|
142
|
-
Ok(core) => {
|
|
143
|
-
let owned_client = Box::into_raw(Box::new(Client {
|
|
138
|
+
match temporalio_client::Connection::connect(connection_options).await {
|
|
139
|
+
Ok(connection) => {
|
|
140
|
+
let owned_client = Box::into_raw(Box::new(Connection {
|
|
144
141
|
runtime: runtime.clone(),
|
|
145
|
-
core,
|
|
142
|
+
core: connection,
|
|
146
143
|
}));
|
|
147
144
|
unsafe {
|
|
148
145
|
callback(user_data.into(), owned_client, std::ptr::null());
|
|
@@ -231,7 +228,7 @@ fn create_callback_based_grpc_service(
|
|
|
231
228
|
}
|
|
232
229
|
|
|
233
230
|
#[unsafe(no_mangle)]
|
|
234
|
-
pub extern "C" fn temporal_core_client_free(client: *mut
|
|
231
|
+
pub extern "C" fn temporal_core_client_free(client: *mut Connection) {
|
|
235
232
|
unsafe {
|
|
236
233
|
let _ = Box::from_raw(client);
|
|
237
234
|
}
|
|
@@ -239,23 +236,33 @@ pub extern "C" fn temporal_core_client_free(client: *mut Client) {
|
|
|
239
236
|
|
|
240
237
|
#[unsafe(no_mangle)]
|
|
241
238
|
pub extern "C" fn temporal_core_client_update_metadata(
|
|
242
|
-
client: *mut
|
|
243
|
-
metadata:
|
|
239
|
+
client: *mut Connection,
|
|
240
|
+
metadata: MetadataRef,
|
|
244
241
|
) {
|
|
245
242
|
let client = unsafe { &*client };
|
|
246
243
|
let _result = client
|
|
247
244
|
.core
|
|
248
|
-
.get_client()
|
|
249
245
|
.set_headers(metadata.to_string_map_on_newlines());
|
|
250
246
|
}
|
|
251
247
|
|
|
252
248
|
#[unsafe(no_mangle)]
|
|
253
|
-
pub extern "C" fn
|
|
249
|
+
pub extern "C" fn temporal_core_client_update_binary_metadata(
|
|
250
|
+
client: *mut Connection,
|
|
251
|
+
metadata: MetadataRef,
|
|
252
|
+
) {
|
|
254
253
|
let client = unsafe { &*client };
|
|
255
|
-
client
|
|
254
|
+
let _result = client
|
|
256
255
|
.core
|
|
257
|
-
.
|
|
258
|
-
|
|
256
|
+
.set_binary_headers(metadata.to_vec_map_on_newlines());
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
#[unsafe(no_mangle)]
|
|
260
|
+
pub extern "C" fn temporal_core_client_update_api_key(
|
|
261
|
+
client: *mut Connection,
|
|
262
|
+
api_key: ByteArrayRef,
|
|
263
|
+
) {
|
|
264
|
+
let client = unsafe { &*client };
|
|
265
|
+
client.core.set_api_key(api_key.to_option_string());
|
|
259
266
|
}
|
|
260
267
|
|
|
261
268
|
/// Callback that is invoked for every gRPC call if set on the client options.
|
|
@@ -271,6 +278,11 @@ pub type ClientGrpcOverrideCallback = Option<
|
|
|
271
278
|
unsafe extern "C" fn(request: *mut ClientGrpcOverrideRequest, user_data: *mut libc::c_void),
|
|
272
279
|
>;
|
|
273
280
|
|
|
281
|
+
pub struct GrpcMetadataHolder {
|
|
282
|
+
pub data: Vec<ByteArrayRef>,
|
|
283
|
+
pub(super) _allocations: Vec<Vec<u8>>,
|
|
284
|
+
}
|
|
285
|
+
|
|
274
286
|
/// Representation of gRPC request for the callback.
|
|
275
287
|
///
|
|
276
288
|
/// Note, temporal_core_client_grpc_override_request_respond is effectively the "free" call for
|
|
@@ -278,7 +290,7 @@ pub type ClientGrpcOverrideCallback = Option<
|
|
|
278
290
|
/// call.
|
|
279
291
|
pub struct ClientGrpcOverrideRequest {
|
|
280
292
|
core: callback_based::GrpcRequest,
|
|
281
|
-
built_headers: OnceCell<
|
|
293
|
+
built_headers: OnceCell<GrpcMetadataHolder>,
|
|
282
294
|
response_sender: oneshot::Sender<Result<callback_based::GrpcSuccessResponse, tonic::Status>>,
|
|
283
295
|
}
|
|
284
296
|
|
|
@@ -341,15 +353,24 @@ pub extern "C" fn temporal_core_client_grpc_override_request_headers(
|
|
|
341
353
|
let req = unsafe { &*req };
|
|
342
354
|
// Lazily create the headers on first access
|
|
343
355
|
let headers = req.built_headers.get_or_init(|| {
|
|
344
|
-
req
|
|
356
|
+
let refs: Vec<Vec<u8>> = req
|
|
357
|
+
.core
|
|
345
358
|
.headers
|
|
346
359
|
.iter()
|
|
347
|
-
.filter_map(|(name, value)|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
360
|
+
.filter_map(|(name, value)| {
|
|
361
|
+
value.to_str().ok().map(|val| {
|
|
362
|
+
let mut entry = format!("{name}\n").into_bytes();
|
|
363
|
+
entry.extend(val.as_bytes());
|
|
364
|
+
entry
|
|
365
|
+
})
|
|
366
|
+
})
|
|
367
|
+
.collect();
|
|
368
|
+
GrpcMetadataHolder {
|
|
369
|
+
data: refs.iter().map(ByteArrayRef::from).collect(),
|
|
370
|
+
_allocations: refs,
|
|
371
|
+
}
|
|
351
372
|
});
|
|
352
|
-
headers.
|
|
373
|
+
headers.into()
|
|
353
374
|
}
|
|
354
375
|
|
|
355
376
|
/// Get a reference to the request protobuf bytes.
|
|
@@ -403,13 +424,13 @@ impl ClientGrpcOverrideResponse {
|
|
|
403
424
|
}
|
|
404
425
|
|
|
405
426
|
fn client_headers_from_metadata_ref(headers: MetadataRef) -> Result<http::HeaderMap, String> {
|
|
406
|
-
let key_values = headers.
|
|
427
|
+
let key_values = headers.to_vec_map_on_newlines();
|
|
407
428
|
let mut header_map = http::HeaderMap::with_capacity(key_values.len());
|
|
408
429
|
for (k, v) in key_values.into_iter() {
|
|
409
|
-
let name = http::HeaderName::try_from(k)
|
|
430
|
+
let name = http::HeaderName::try_from(&k)
|
|
410
431
|
.map_err(|e| format!("Invalid header name '{k}': {e}"))?;
|
|
411
|
-
let value = http::HeaderValue::
|
|
412
|
-
.map_err(|e| format!("Invalid header value '{v}': {e}"))?;
|
|
432
|
+
let value = http::HeaderValue::from_bytes(v.as_slice())
|
|
433
|
+
.map_err(|e| format!("Invalid header value '{v:?}': {e}"))?;
|
|
413
434
|
header_map.insert(name, value);
|
|
414
435
|
}
|
|
415
436
|
Ok(header_map)
|
|
@@ -423,6 +444,7 @@ pub struct RpcCallOptions {
|
|
|
423
444
|
pub req: ByteArrayRef,
|
|
424
445
|
pub retry: bool,
|
|
425
446
|
pub metadata: MetadataRef,
|
|
447
|
+
pub binary_metadata: MetadataRef,
|
|
426
448
|
/// 0 means no timeout
|
|
427
449
|
pub timeout_millis: u32,
|
|
428
450
|
pub cancellation_token: *const CancellationToken,
|
|
@@ -471,7 +493,7 @@ macro_rules! service_call {
|
|
|
471
493
|
/// Client, options, and user data must live through callback.
|
|
472
494
|
#[unsafe(no_mangle)]
|
|
473
495
|
pub extern "C" fn temporal_core_client_rpc_call(
|
|
474
|
-
client: *mut
|
|
496
|
+
client: *mut Connection,
|
|
475
497
|
options: *const RpcCallOptions,
|
|
476
498
|
user_data: *mut libc::c_void,
|
|
477
499
|
callback: ClientRpcCallCallback,
|
|
@@ -533,18 +555,24 @@ macro_rules! rpc_call_on_trait {
|
|
|
533
555
|
if $call.retry {
|
|
534
556
|
rpc_resp($trait::$call_name(&mut $client, rpc_req($call)?).await)
|
|
535
557
|
} else {
|
|
536
|
-
|
|
558
|
+
// Disable retries for this call
|
|
559
|
+
*$client.retry_options_mut() = RetryOptions::no_retries();
|
|
560
|
+
rpc_resp($trait::$call_name(&mut $client, rpc_req($call)?).await)
|
|
537
561
|
}
|
|
538
562
|
};
|
|
539
563
|
}
|
|
540
564
|
|
|
541
565
|
async fn call_workflow_service(
|
|
542
|
-
client: &
|
|
566
|
+
client: &CoreConnection,
|
|
543
567
|
call: &RpcCallOptions,
|
|
544
568
|
) -> anyhow::Result<Vec<u8>> {
|
|
545
569
|
let rpc = call.rpc.to_str();
|
|
546
570
|
let mut client = client.clone();
|
|
547
571
|
match rpc {
|
|
572
|
+
"CountActivityExecutions" => {
|
|
573
|
+
rpc_call_on_trait!(client, call, WorkflowService, count_activity_executions)
|
|
574
|
+
}
|
|
575
|
+
"CountSchedules" => rpc_call_on_trait!(client, call, WorkflowService, count_schedules),
|
|
548
576
|
"CountWorkflowExecutions" => {
|
|
549
577
|
rpc_call_on_trait!(client, call, WorkflowService, count_workflow_executions)
|
|
550
578
|
}
|
|
@@ -553,6 +581,9 @@ async fn call_workflow_service(
|
|
|
553
581
|
rpc_call_on_trait!(client, call, WorkflowService, create_workflow_rule)
|
|
554
582
|
}
|
|
555
583
|
"DeleteSchedule" => rpc_call_on_trait!(client, call, WorkflowService, delete_schedule),
|
|
584
|
+
"DeleteActivityExecution" => {
|
|
585
|
+
rpc_call_on_trait!(client, call, WorkflowService, delete_activity_execution)
|
|
586
|
+
}
|
|
556
587
|
"DeleteWorkerDeployment" => {
|
|
557
588
|
rpc_call_on_trait!(client, call, WorkflowService, delete_worker_deployment)
|
|
558
589
|
}
|
|
@@ -573,6 +604,9 @@ async fn call_workflow_service(
|
|
|
573
604
|
"DeprecateNamespace" => {
|
|
574
605
|
rpc_call_on_trait!(client, call, WorkflowService, deprecate_namespace)
|
|
575
606
|
}
|
|
607
|
+
"DescribeActivityExecution" => {
|
|
608
|
+
rpc_call_on_trait!(client, call, WorkflowService, describe_activity_execution)
|
|
609
|
+
}
|
|
576
610
|
"DescribeBatchOperation" => {
|
|
577
611
|
rpc_call_on_trait!(client, call, WorkflowService, describe_batch_operation)
|
|
578
612
|
}
|
|
@@ -651,6 +685,9 @@ async fn call_workflow_service(
|
|
|
651
685
|
get_workflow_execution_history_reverse
|
|
652
686
|
)
|
|
653
687
|
}
|
|
688
|
+
"ListActivityExecutions" => {
|
|
689
|
+
rpc_call_on_trait!(client, call, WorkflowService, list_activity_executions)
|
|
690
|
+
}
|
|
654
691
|
"ListArchivedWorkflowExecutions" => {
|
|
655
692
|
rpc_call_on_trait!(
|
|
656
693
|
client,
|
|
@@ -692,6 +729,12 @@ async fn call_workflow_service(
|
|
|
692
729
|
}
|
|
693
730
|
"PatchSchedule" => rpc_call_on_trait!(client, call, WorkflowService, patch_schedule),
|
|
694
731
|
"PauseActivity" => rpc_call_on_trait!(client, call, WorkflowService, pause_activity),
|
|
732
|
+
"PauseWorkflowExecution" => {
|
|
733
|
+
rpc_call_on_trait!(client, call, WorkflowService, pause_workflow_execution)
|
|
734
|
+
}
|
|
735
|
+
"PollActivityExecution" => {
|
|
736
|
+
rpc_call_on_trait!(client, call, WorkflowService, poll_activity_execution)
|
|
737
|
+
}
|
|
695
738
|
"PollActivityTaskQueue" => {
|
|
696
739
|
rpc_call_on_trait!(client, call, WorkflowService, poll_activity_task_queue)
|
|
697
740
|
}
|
|
@@ -728,6 +771,14 @@ async fn call_workflow_service(
|
|
|
728
771
|
"RegisterNamespace" => {
|
|
729
772
|
rpc_call_on_trait!(client, call, WorkflowService, register_namespace)
|
|
730
773
|
}
|
|
774
|
+
"RequestCancelActivityExecution" => {
|
|
775
|
+
rpc_call_on_trait!(
|
|
776
|
+
client,
|
|
777
|
+
call,
|
|
778
|
+
WorkflowService,
|
|
779
|
+
request_cancel_activity_execution
|
|
780
|
+
)
|
|
781
|
+
}
|
|
731
782
|
"RequestCancelWorkflowExecution" => {
|
|
732
783
|
rpc_call_on_trait!(
|
|
733
784
|
client,
|
|
@@ -837,15 +888,21 @@ async fn call_workflow_service(
|
|
|
837
888
|
"SignalWorkflowExecution" => {
|
|
838
889
|
rpc_call_on_trait!(client, call, WorkflowService, signal_workflow_execution)
|
|
839
890
|
}
|
|
840
|
-
"
|
|
841
|
-
rpc_call_on_trait!(client, call, WorkflowService,
|
|
891
|
+
"StartActivityExecution" => {
|
|
892
|
+
rpc_call_on_trait!(client, call, WorkflowService, start_activity_execution)
|
|
842
893
|
}
|
|
843
894
|
"StartBatchOperation" => {
|
|
844
895
|
rpc_call_on_trait!(client, call, WorkflowService, start_batch_operation)
|
|
845
896
|
}
|
|
897
|
+
"StartWorkflowExecution" => {
|
|
898
|
+
rpc_call_on_trait!(client, call, WorkflowService, start_workflow_execution)
|
|
899
|
+
}
|
|
846
900
|
"StopBatchOperation" => {
|
|
847
901
|
rpc_call_on_trait!(client, call, WorkflowService, stop_batch_operation)
|
|
848
902
|
}
|
|
903
|
+
"TerminateActivityExecution" => {
|
|
904
|
+
rpc_call_on_trait!(client, call, WorkflowService, terminate_activity_execution)
|
|
905
|
+
}
|
|
849
906
|
"TerminateWorkflowExecution" => {
|
|
850
907
|
rpc_call_on_trait!(client, call, WorkflowService, terminate_workflow_execution)
|
|
851
908
|
}
|
|
@@ -855,6 +912,9 @@ async fn call_workflow_service(
|
|
|
855
912
|
"UnpauseActivity" => {
|
|
856
913
|
rpc_call_on_trait!(client, call, WorkflowService, unpause_activity)
|
|
857
914
|
}
|
|
915
|
+
"UnpauseWorkflowExecution" => {
|
|
916
|
+
rpc_call_on_trait!(client, call, WorkflowService, unpause_workflow_execution)
|
|
917
|
+
}
|
|
858
918
|
"UpdateActivityOptions" => {
|
|
859
919
|
rpc_call_on_trait!(client, call, WorkflowService, update_activity_options)
|
|
860
920
|
}
|
|
@@ -904,7 +964,7 @@ async fn call_workflow_service(
|
|
|
904
964
|
}
|
|
905
965
|
|
|
906
966
|
async fn call_operator_service(
|
|
907
|
-
client: &
|
|
967
|
+
client: &CoreConnection,
|
|
908
968
|
call: &RpcCallOptions,
|
|
909
969
|
) -> anyhow::Result<Vec<u8>> {
|
|
910
970
|
let rpc = call.rpc.to_str();
|
|
@@ -944,7 +1004,10 @@ async fn call_operator_service(
|
|
|
944
1004
|
}
|
|
945
1005
|
}
|
|
946
1006
|
|
|
947
|
-
async fn call_cloud_service(
|
|
1007
|
+
async fn call_cloud_service(
|
|
1008
|
+
client: &CoreConnection,
|
|
1009
|
+
call: &RpcCallOptions,
|
|
1010
|
+
) -> anyhow::Result<Vec<u8>> {
|
|
948
1011
|
let rpc = call.rpc.to_str();
|
|
949
1012
|
let mut client = client.clone();
|
|
950
1013
|
match rpc {
|
|
@@ -1073,7 +1136,10 @@ async fn call_cloud_service(client: &CoreClient, call: &RpcCallOptions) -> anyho
|
|
|
1073
1136
|
}
|
|
1074
1137
|
}
|
|
1075
1138
|
|
|
1076
|
-
async fn call_test_service(
|
|
1139
|
+
async fn call_test_service(
|
|
1140
|
+
client: &CoreConnection,
|
|
1141
|
+
call: &RpcCallOptions,
|
|
1142
|
+
) -> anyhow::Result<Vec<u8>> {
|
|
1077
1143
|
let rpc = call.rpc.to_str();
|
|
1078
1144
|
let mut client = client.clone();
|
|
1079
1145
|
match rpc {
|
|
@@ -1090,7 +1156,7 @@ async fn call_test_service(client: &CoreClient, call: &RpcCallOptions) -> anyhow
|
|
|
1090
1156
|
}
|
|
1091
1157
|
|
|
1092
1158
|
async fn call_health_service(
|
|
1093
|
-
client: &
|
|
1159
|
+
client: &CoreConnection,
|
|
1094
1160
|
call: &RpcCallOptions,
|
|
1095
1161
|
) -> anyhow::Result<Vec<u8>> {
|
|
1096
1162
|
let rpc = call.rpc.to_str();
|
|
@@ -1110,9 +1176,17 @@ fn rpc_req<P: prost::Message + Default>(
|
|
|
1110
1176
|
let proto = P::decode(call.req.to_slice())?;
|
|
1111
1177
|
let mut req = tonic::Request::new(proto);
|
|
1112
1178
|
if call.metadata.size > 0 {
|
|
1113
|
-
for (k, v) in call.metadata.
|
|
1179
|
+
for (k, v) in call.metadata.to_string_map_on_newlines() {
|
|
1114
1180
|
req.metadata_mut()
|
|
1115
|
-
.insert(MetadataKey::from_str(k)?, v.parse()?);
|
|
1181
|
+
.insert(MetadataKey::from_str(k.as_str())?, v.parse()?);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
if call.binary_metadata.size > 0 {
|
|
1185
|
+
for (k, v) in call.binary_metadata.to_vec_map_on_newlines() {
|
|
1186
|
+
req.metadata_mut().insert_bin(
|
|
1187
|
+
MetadataKey::from_str(k.as_str())?,
|
|
1188
|
+
MetadataValue::from_bytes(v.as_slice()),
|
|
1189
|
+
);
|
|
1116
1190
|
}
|
|
1117
1191
|
}
|
|
1118
1192
|
if call.timeout_millis > 0 {
|
|
@@ -1129,10 +1203,10 @@ where
|
|
|
1129
1203
|
Ok(res?.get_ref().encode_to_vec())
|
|
1130
1204
|
}
|
|
1131
1205
|
|
|
1132
|
-
impl TryFrom<&
|
|
1206
|
+
impl TryFrom<&ConnectionOptions> for temporalio_client::ConnectionOptions {
|
|
1133
1207
|
type Error = anyhow::Error;
|
|
1134
1208
|
|
|
1135
|
-
fn try_from(opts: &
|
|
1209
|
+
fn try_from(opts: &ConnectionOptions) -> anyhow::Result<Self> {
|
|
1136
1210
|
let tls_cfg = unsafe { opts.tls_options.as_ref() }
|
|
1137
1211
|
.map(|c| c.try_into())
|
|
1138
1212
|
.transpose()?;
|
|
@@ -1148,34 +1222,42 @@ impl TryFrom<&ClientOptions> for CoreClientOptions {
|
|
|
1148
1222
|
Some(opts.metadata.to_string_map_on_newlines())
|
|
1149
1223
|
};
|
|
1150
1224
|
|
|
1225
|
+
let binary_headers = if opts.binary_metadata.size == 0 {
|
|
1226
|
+
None
|
|
1227
|
+
} else {
|
|
1228
|
+
Some(opts.binary_metadata.to_vec_map_on_newlines())
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1151
1231
|
let api_key = opts.api_key.to_option_string();
|
|
1152
1232
|
|
|
1153
1233
|
let http_connect_proxy =
|
|
1154
1234
|
unsafe { opts.http_connect_proxy_options.as_ref() }.map(Into::into);
|
|
1155
1235
|
|
|
1156
|
-
Ok(
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1236
|
+
Ok(
|
|
1237
|
+
temporalio_client::ConnectionOptions::new(Url::parse(opts.target_url.to_str())?)
|
|
1238
|
+
.client_name(opts.client_name.to_string())
|
|
1239
|
+
.client_version(opts.client_version.to_string())
|
|
1240
|
+
.identity(opts.identity.to_string())
|
|
1241
|
+
.retry_options(
|
|
1242
|
+
unsafe { opts.retry_options.as_ref() }
|
|
1243
|
+
.map_or(RetryOptions::default(), |c| c.into()),
|
|
1244
|
+
)
|
|
1245
|
+
.keep_alive(keep_alive)
|
|
1246
|
+
.maybe_headers(headers)
|
|
1247
|
+
.maybe_binary_headers(binary_headers)
|
|
1248
|
+
.maybe_api_key(api_key)
|
|
1249
|
+
.maybe_http_connect_proxy(http_connect_proxy)
|
|
1250
|
+
.maybe_tls_options(tls_cfg)
|
|
1251
|
+
.build(),
|
|
1252
|
+
)
|
|
1171
1253
|
}
|
|
1172
1254
|
}
|
|
1173
1255
|
|
|
1174
|
-
impl TryFrom<&ClientTlsOptions> for
|
|
1256
|
+
impl TryFrom<&ClientTlsOptions> for temporalio_client::TlsOptions {
|
|
1175
1257
|
type Error = anyhow::Error;
|
|
1176
1258
|
|
|
1177
1259
|
fn try_from(opts: &ClientTlsOptions) -> anyhow::Result<Self> {
|
|
1178
|
-
Ok(
|
|
1260
|
+
Ok(temporalio_client::TlsOptions {
|
|
1179
1261
|
server_root_ca_cert: opts.server_root_ca_cert.to_option_vec(),
|
|
1180
1262
|
domain: opts.domain.to_option_string(),
|
|
1181
1263
|
client_tls_options: match (
|
|
@@ -1183,10 +1265,12 @@ impl TryFrom<&ClientTlsOptions> for CoreTlsOptions {
|
|
|
1183
1265
|
opts.client_private_key.to_option_vec(),
|
|
1184
1266
|
) {
|
|
1185
1267
|
(None, None) => None,
|
|
1186
|
-
(Some(client_cert), Some(client_private_key)) =>
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1268
|
+
(Some(client_cert), Some(client_private_key)) => {
|
|
1269
|
+
Some(temporalio_client::ClientTlsOptions {
|
|
1270
|
+
client_cert,
|
|
1271
|
+
client_private_key,
|
|
1272
|
+
})
|
|
1273
|
+
}
|
|
1190
1274
|
_ => {
|
|
1191
1275
|
return Err(anyhow::anyhow!(
|
|
1192
1276
|
"Must have both client cert and private key or neither"
|
|
@@ -1197,9 +1281,9 @@ impl TryFrom<&ClientTlsOptions> for CoreTlsOptions {
|
|
|
1197
1281
|
}
|
|
1198
1282
|
}
|
|
1199
1283
|
|
|
1200
|
-
impl From<&ClientRetryOptions> for RetryOptions {
|
|
1284
|
+
impl From<&ClientRetryOptions> for temporalio_client::RetryOptions {
|
|
1201
1285
|
fn from(opts: &ClientRetryOptions) -> Self {
|
|
1202
|
-
RetryOptions {
|
|
1286
|
+
temporalio_client::RetryOptions {
|
|
1203
1287
|
initial_interval: Duration::from_millis(opts.initial_interval_millis),
|
|
1204
1288
|
randomization_factor: opts.randomization_factor,
|
|
1205
1289
|
multiplier: opts.multiplier,
|
|
@@ -1214,18 +1298,18 @@ impl From<&ClientRetryOptions> for RetryOptions {
|
|
|
1214
1298
|
}
|
|
1215
1299
|
}
|
|
1216
1300
|
|
|
1217
|
-
impl From<&ClientKeepAliveOptions> for
|
|
1301
|
+
impl From<&ClientKeepAliveOptions> for temporalio_client::ClientKeepAliveOptions {
|
|
1218
1302
|
fn from(opts: &ClientKeepAliveOptions) -> Self {
|
|
1219
|
-
|
|
1303
|
+
temporalio_client::ClientKeepAliveOptions {
|
|
1220
1304
|
interval: Duration::from_millis(opts.interval_millis),
|
|
1221
1305
|
timeout: Duration::from_millis(opts.timeout_millis),
|
|
1222
1306
|
}
|
|
1223
1307
|
}
|
|
1224
1308
|
}
|
|
1225
1309
|
|
|
1226
|
-
impl From<&ClientHttpConnectProxyOptions> for HttpConnectProxyOptions {
|
|
1310
|
+
impl From<&ClientHttpConnectProxyOptions> for temporalio_client::proxy::HttpConnectProxyOptions {
|
|
1227
1311
|
fn from(opts: &ClientHttpConnectProxyOptions) -> Self {
|
|
1228
|
-
HttpConnectProxyOptions {
|
|
1312
|
+
temporalio_client::proxy::HttpConnectProxyOptions {
|
|
1229
1313
|
target_addr: opts.target_host.to_string(),
|
|
1230
1314
|
basic_auth: if opts.username.size != 0 && opts.password.size != 0 {
|
|
1231
1315
|
Some((opts.username.to_string(), opts.password.to_string()))
|
|
@@ -1235,3 +1319,12 @@ impl From<&ClientHttpConnectProxyOptions> for HttpConnectProxyOptions {
|
|
|
1235
1319
|
}
|
|
1236
1320
|
}
|
|
1237
1321
|
}
|
|
1322
|
+
|
|
1323
|
+
impl From<&GrpcMetadataHolder> for MetadataRef {
|
|
1324
|
+
fn from(value: &GrpcMetadataHolder) -> Self {
|
|
1325
|
+
MetadataRef {
|
|
1326
|
+
data: value.data.as_ptr(),
|
|
1327
|
+
size: value.data.len(),
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
@@ -27,6 +27,8 @@ pub struct ByteArrayRef {
|
|
|
27
27
|
pub size: libc::size_t,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
unsafe impl Sync for ByteArrayRef {}
|
|
31
|
+
|
|
30
32
|
impl ByteArrayRef {
|
|
31
33
|
pub fn empty() -> ByteArrayRef {
|
|
32
34
|
static EMPTY: &str = "";
|
|
@@ -98,6 +100,24 @@ impl ByteArrayRef {
|
|
|
98
100
|
.map(|(k, v)| (k.to_string(), v.to_string()))
|
|
99
101
|
.collect()
|
|
100
102
|
}
|
|
103
|
+
|
|
104
|
+
pub fn to_option_str_key_value_pair(&self) -> Option<(&str, ByteArrayRef)> {
|
|
105
|
+
if let Some(index) = self.to_slice().iter().position(|&x| x == b'\n') {
|
|
106
|
+
let key_str = unsafe {
|
|
107
|
+
std::str::from_utf8_unchecked(std::slice::from_raw_parts(self.data, index))
|
|
108
|
+
};
|
|
109
|
+
let value = ByteArrayRef {
|
|
110
|
+
data: unsafe { self.data.add(index + 1) },
|
|
111
|
+
size: self.size - index - 1,
|
|
112
|
+
};
|
|
113
|
+
let _value_str = unsafe {
|
|
114
|
+
std::str::from_utf8_unchecked(std::slice::from_raw_parts(value.data, value.size))
|
|
115
|
+
};
|
|
116
|
+
Some((key_str, value))
|
|
117
|
+
} else {
|
|
118
|
+
None
|
|
119
|
+
}
|
|
120
|
+
}
|
|
101
121
|
}
|
|
102
122
|
|
|
103
123
|
impl From<&str> for ByteArrayRef {
|
|
@@ -118,6 +138,15 @@ impl From<&[u8]> for ByteArrayRef {
|
|
|
118
138
|
}
|
|
119
139
|
}
|
|
120
140
|
|
|
141
|
+
impl From<&Vec<u8>> for ByteArrayRef {
|
|
142
|
+
fn from(value: &Vec<u8>) -> ByteArrayRef {
|
|
143
|
+
ByteArrayRef {
|
|
144
|
+
data: value.as_ptr(),
|
|
145
|
+
size: value.len(),
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
121
150
|
impl<T> From<Option<T>> for ByteArrayRef
|
|
122
151
|
where
|
|
123
152
|
T: Into<ByteArrayRef>,
|
|
@@ -134,19 +163,74 @@ pub struct ByteArrayRefArray {
|
|
|
134
163
|
}
|
|
135
164
|
|
|
136
165
|
impl ByteArrayRefArray {
|
|
166
|
+
pub fn empty() -> ByteArrayRefArray {
|
|
167
|
+
static EMPTY: &[ByteArrayRef] = &[];
|
|
168
|
+
EMPTY.into()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
pub fn to_slice(&self) -> &[ByteArrayRef] {
|
|
172
|
+
unsafe { std::slice::from_raw_parts(self.data, self.size) }
|
|
173
|
+
}
|
|
174
|
+
|
|
137
175
|
pub fn to_str_vec(&self) -> Vec<&str> {
|
|
138
176
|
if self.size == 0 {
|
|
139
177
|
vec![]
|
|
140
178
|
} else {
|
|
141
|
-
|
|
142
|
-
|
|
179
|
+
self.to_slice().iter().map(ByteArrayRef::to_str).collect()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
fn to_bytearrayref_map_on_newlines(&self) -> HashMap<&str, ByteArrayRef> {
|
|
184
|
+
if self.size == 0 {
|
|
185
|
+
HashMap::new()
|
|
186
|
+
} else {
|
|
187
|
+
self.to_slice()
|
|
188
|
+
.iter()
|
|
189
|
+
.filter_map(ByteArrayRef::to_option_str_key_value_pair)
|
|
190
|
+
.collect()
|
|
143
191
|
}
|
|
144
192
|
}
|
|
193
|
+
|
|
194
|
+
pub fn to_string_map_on_newlines(&self) -> HashMap<String, String> {
|
|
195
|
+
self.to_bytearrayref_map_on_newlines()
|
|
196
|
+
.iter()
|
|
197
|
+
.map(|(k, v)| (k.to_string(), v.to_string()))
|
|
198
|
+
.collect()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
pub fn to_vec_map_on_newlines(&self) -> HashMap<String, Vec<u8>> {
|
|
202
|
+
self.to_bytearrayref_map_on_newlines()
|
|
203
|
+
.iter()
|
|
204
|
+
.map(|(k, v)| (k.to_string(), v.to_vec()))
|
|
205
|
+
.collect()
|
|
206
|
+
}
|
|
145
207
|
}
|
|
146
208
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
209
|
+
impl From<&[ByteArrayRef]> for ByteArrayRefArray {
|
|
210
|
+
fn from(value: &[ByteArrayRef]) -> ByteArrayRefArray {
|
|
211
|
+
ByteArrayRefArray {
|
|
212
|
+
data: value.as_ptr(),
|
|
213
|
+
size: value.len(),
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
impl<T> From<Option<T>> for ByteArrayRefArray
|
|
219
|
+
where
|
|
220
|
+
T: Into<ByteArrayRefArray>,
|
|
221
|
+
{
|
|
222
|
+
fn from(value: Option<T>) -> ByteArrayRefArray {
|
|
223
|
+
value.map(Into::into).unwrap_or(ByteArrayRefArray::empty())
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/// Each ByteArrayRef is `<key>\n<value>`.
|
|
228
|
+
/// Keys cannot contain a newline.
|
|
229
|
+
pub type MetadataRef = ByteArrayRefArray;
|
|
230
|
+
|
|
231
|
+
/// Data is `<key1>\n<value1>\n<key2>\n<value2>`.
|
|
232
|
+
/// Keys and values cannot contain a newline within.
|
|
233
|
+
pub type NewlineDelimitedMapRef = ByteArrayRef;
|
|
150
234
|
|
|
151
235
|
#[repr(C)]
|
|
152
236
|
pub struct ByteArray {
|