@temporalio/core-bridge 1.6.0 → 1.7.1
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 +520 -456
- package/lib/index.d.ts +8 -6
- package/lib/index.js.map +1 -1
- package/package.json +8 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.buildkite/docker/Dockerfile +2 -2
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.buildkite/pipeline.yml +1 -1
- package/sdk-core/.github/workflows/heavy.yml +1 -0
- package/sdk-core/README.md +13 -7
- package/sdk-core/client/src/lib.rs +27 -9
- package/sdk-core/client/src/metrics.rs +17 -8
- package/sdk-core/client/src/raw.rs +3 -3
- package/sdk-core/core/Cargo.toml +3 -4
- package/sdk-core/core/src/abstractions/take_cell.rs +28 -0
- package/sdk-core/core/src/abstractions.rs +197 -18
- package/sdk-core/core/src/core_tests/activity_tasks.rs +137 -45
- package/sdk-core/core/src/core_tests/child_workflows.rs +6 -5
- package/sdk-core/core/src/core_tests/determinism.rs +212 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +183 -36
- package/sdk-core/core/src/core_tests/queries.rs +32 -14
- package/sdk-core/core/src/core_tests/workers.rs +8 -5
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +340 -51
- package/sdk-core/core/src/ephemeral_server/mod.rs +110 -8
- package/sdk-core/core/src/internal_flags.rs +141 -0
- package/sdk-core/core/src/lib.rs +14 -9
- package/sdk-core/core/src/replay/mod.rs +16 -27
- package/sdk-core/core/src/telemetry/metrics.rs +69 -35
- package/sdk-core/core/src/telemetry/mod.rs +38 -14
- package/sdk-core/core/src/telemetry/prometheus_server.rs +19 -13
- package/sdk-core/core/src/test_help/mod.rs +65 -13
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +119 -160
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- package/sdk-core/core/src/worker/activities/local_activities.rs +122 -6
- package/sdk-core/core/src/worker/activities.rs +347 -173
- package/sdk-core/core/src/worker/client/mocks.rs +22 -2
- package/sdk-core/core/src/worker/client.rs +18 -2
- package/sdk-core/core/src/worker/mod.rs +137 -44
- package/sdk-core/core/src/worker/workflow/history_update.rs +132 -51
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +207 -166
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +157 -82
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +12 -12
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +13 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +170 -60
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +24 -16
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +6 -8
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +320 -204
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +10 -13
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +15 -23
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +187 -46
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +237 -111
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -13
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +10 -6
- package/sdk-core/core/src/worker/workflow/managed_run.rs +81 -62
- package/sdk-core/core/src/worker/workflow/mod.rs +341 -79
- package/sdk-core/core/src/worker/workflow/run_cache.rs +18 -11
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +15 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +2 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +75 -52
- package/sdk-core/core-api/Cargo.toml +0 -1
- package/sdk-core/core-api/src/lib.rs +13 -7
- package/sdk-core/core-api/src/telemetry.rs +4 -6
- package/sdk-core/core-api/src/worker.rs +5 -0
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +80 -55
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +22 -68
- package/sdk-core/histories/ends_empty_wft_complete.bin +0 -0
- package/sdk-core/histories/old_change_marker_format.bin +0 -0
- package/sdk-core/protos/api_upstream/.github/CODEOWNERS +2 -1
- package/sdk-core/protos/api_upstream/Makefile +1 -1
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +5 -17
- package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +11 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +1 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +5 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +22 -6
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +48 -19
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -0
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/{enums/v1/interaction_type.proto → protocol/v1/message.proto} +29 -11
- package/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +111 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +59 -28
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +2 -2
- package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +7 -8
- package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +10 -7
- package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +19 -30
- package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +8 -0
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +65 -60
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +85 -84
- package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +9 -3
- package/sdk-core/sdk/Cargo.toml +1 -1
- package/sdk-core/sdk/src/lib.rs +21 -5
- package/sdk-core/sdk/src/workflow_context/options.rs +7 -1
- package/sdk-core/sdk/src/workflow_context.rs +24 -17
- package/sdk-core/sdk/src/workflow_future.rs +9 -3
- package/sdk-core/sdk-core-protos/src/history_builder.rs +114 -89
- package/sdk-core/sdk-core-protos/src/history_info.rs +6 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +205 -64
- package/sdk-core/test-utils/src/canned_histories.rs +106 -296
- package/sdk-core/test-utils/src/lib.rs +32 -5
- package/sdk-core/tests/heavy_tests.rs +10 -43
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -3
- package/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
- package/sdk-core/tests/integ_tests/polling_tests.rs +3 -8
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -2
- package/sdk-core/tests/integ_tests/visibility_tests.rs +34 -23
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +97 -81
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +80 -3
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +5 -1
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +25 -3
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +2 -4
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +30 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +64 -0
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +4 -0
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +3 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +7 -2
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +8 -8
- package/sdk-core/tests/main.rs +16 -25
- package/sdk-core/tests/runner.rs +11 -9
- package/src/conversions.rs +14 -8
- package/src/runtime.rs +9 -8
- package/ts/index.ts +8 -6
- package/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +0 -87
package/lib/index.d.ts
CHANGED
|
@@ -341,10 +341,10 @@ export interface TimeSkippingServerConfig {
|
|
|
341
341
|
extraArgs?: string[];
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
|
-
* Configuration for
|
|
344
|
+
* Configuration for the Temporal CLI dev server.
|
|
345
345
|
*/
|
|
346
|
-
export interface
|
|
347
|
-
type: '
|
|
346
|
+
export interface DevServerConfig {
|
|
347
|
+
type: 'dev-server';
|
|
348
348
|
executable?: EphemeralServerExecutable;
|
|
349
349
|
/**
|
|
350
350
|
* Namespace to use - created at startup.
|
|
@@ -359,11 +359,13 @@ export interface TemporaliteConfig {
|
|
|
359
359
|
*/
|
|
360
360
|
ip?: string;
|
|
361
361
|
/**
|
|
362
|
-
* Sqlite DB filename if persisting or non-persistent if none.
|
|
362
|
+
* Sqlite DB filename if persisting or non-persistent if none (default).
|
|
363
363
|
*/
|
|
364
364
|
db_filename?: string;
|
|
365
365
|
/**
|
|
366
366
|
* Whether to enable the UI.
|
|
367
|
+
*
|
|
368
|
+
* @default false
|
|
367
369
|
*/
|
|
368
370
|
ui?: boolean;
|
|
369
371
|
/**
|
|
@@ -386,9 +388,9 @@ export interface TemporaliteConfig {
|
|
|
386
388
|
/**
|
|
387
389
|
* Configuration for spawning an ephemeral Temporal server.
|
|
388
390
|
*
|
|
389
|
-
* Both the time-skipping test server and
|
|
391
|
+
* Both the time-skipping test server and Temporal CLI dev server are supported.
|
|
390
392
|
*/
|
|
391
|
-
export declare type EphemeralServerConfig = TimeSkippingServerConfig |
|
|
393
|
+
export declare type EphemeralServerConfig = TimeSkippingServerConfig | DevServerConfig;
|
|
392
394
|
export interface Worker {
|
|
393
395
|
type: 'Worker';
|
|
394
396
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AAmgBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/core-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Temporal.io SDK Core<>Node bridge",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@opentelemetry/api": "^1.3.0",
|
|
26
|
-
"@temporalio/common": "1.
|
|
26
|
+
"@temporalio/common": "1.7.1",
|
|
27
27
|
"arg": "^5.0.2",
|
|
28
28
|
"cargo-cp-artifact": "^0.1.6",
|
|
29
29
|
"which": "^2.0.2"
|
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"bugs": {
|
|
32
32
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
33
33
|
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/temporalio/sdk-typescript.git",
|
|
37
|
+
"directory": "packages/core-bridge"
|
|
38
|
+
},
|
|
34
39
|
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/packages/core-bridge",
|
|
35
40
|
"files": [
|
|
36
41
|
"scripts",
|
|
@@ -48,5 +53,5 @@
|
|
|
48
53
|
"publishConfig": {
|
|
49
54
|
"access": "public"
|
|
50
55
|
},
|
|
51
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "368aa83c631555fc31cff25f4af8817d069878d8"
|
|
52
57
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
FROM rust:1.
|
|
1
|
+
FROM rust:1.68
|
|
2
2
|
|
|
3
3
|
RUN rustup component add rustfmt && \
|
|
4
4
|
rustup component add clippy
|
|
5
5
|
|
|
6
|
-
RUN cargo install cargo-tarpaulin
|
|
6
|
+
# RUN cargo install cargo-tarpaulin
|
|
7
7
|
RUN apt-get update && apt-get install -y protobuf-compiler
|
|
8
8
|
|
|
9
9
|
WORKDIR /sdk-core
|
|
@@ -29,7 +29,7 @@ steps:
|
|
|
29
29
|
agents:
|
|
30
30
|
queue: "default"
|
|
31
31
|
docker: "*"
|
|
32
|
-
command: "cargo
|
|
32
|
+
command: "cargo test -- --include-ignored"
|
|
33
33
|
artifact_paths:
|
|
34
34
|
- "tarpaulin-report.html"
|
|
35
35
|
- "machine_coverage/*"
|
package/sdk-core/README.md
CHANGED
|
@@ -4,20 +4,20 @@ Core SDK that can be used as a base for other Temporal SDKs. It is currently use
|
|
|
4
4
|
|
|
5
5
|
- [TypeScript SDK](https://github.com/temporalio/sdk-typescript/)
|
|
6
6
|
- [Python SDK](https://github.com/temporalio/sdk-python/)
|
|
7
|
+
- [.NET SDK](https://github.com/temporalio/sdk-dotnet/)
|
|
8
|
+
- [Ruby SDK](https://github.com/temporalio/sdk-ruby/)
|
|
7
9
|
|
|
8
10
|
For the reasoning behind the Core SDK, see:
|
|
9
11
|
|
|
10
12
|
- [Why Rust powers Temporal’s new Core SDK](https://temporal.io/blog/why-rust-powers-core-sdk).
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
See the [Architecture](ARCHITECTURE.md) doc for some high-level information.
|
|
15
|
-
|
|
16
|
-
## Dependencies
|
|
17
|
-
* Protobuf compiler
|
|
14
|
+
See the [Architecture](ARCHITECTURE.md) doc for some high-level information about how Core works
|
|
15
|
+
and how language layers interact with it.
|
|
18
16
|
|
|
19
17
|
# Development
|
|
20
18
|
|
|
19
|
+
You will need the `protoc` protobuf compiler installed to build Core.
|
|
20
|
+
|
|
21
21
|
This repo is composed of multiple crates:
|
|
22
22
|
* temporal-sdk-core-protos `./sdk-core-protos` - Holds the generated proto code and extensions
|
|
23
23
|
* temporal-client `./client` - Defines client(s) for interacting with the Temporal gRPC service
|
|
@@ -31,7 +31,6 @@ Visualized (dev dependencies are in blue):
|
|
|
31
31
|
|
|
32
32
|

|
|
33
33
|
|
|
34
|
-
|
|
35
34
|
All the following commands are enforced for each pull request:
|
|
36
35
|
|
|
37
36
|
## Building and testing
|
|
@@ -109,3 +108,10 @@ Any error which is returned from a public interface should be well-typed, and we
|
|
|
109
108
|
Errors returned from things only used in testing are free to use
|
|
110
109
|
[anyhow](https://github.com/dtolnay/anyhow) for less verbosity.
|
|
111
110
|
|
|
111
|
+
|
|
112
|
+
# The Rust "SDK"
|
|
113
|
+
This repo contains a *prototype* Rust sdk in the `sdk/` directory. This SDK should be considered
|
|
114
|
+
pre-alpha in terms of its API surface. Since it's still using Core underneath, it is generally
|
|
115
|
+
functional. We do not currently have any firm plans to productionize this SDK. If you want to write
|
|
116
|
+
workflows and activities in Rust, feel free to use it - but be aware that the API may change at any
|
|
117
|
+
time without warning and we do not provide any support guarantees.
|
|
@@ -13,6 +13,7 @@ mod retry;
|
|
|
13
13
|
mod workflow_handle;
|
|
14
14
|
|
|
15
15
|
pub use crate::retry::{CallType, RetryClient, RETRYABLE_ERROR_CODES};
|
|
16
|
+
pub use metrics::ClientMetricProvider;
|
|
16
17
|
pub use raw::{HealthService, OperatorService, TestService, WorkflowService};
|
|
17
18
|
pub use temporal_sdk_core_protos::temporal::api::{
|
|
18
19
|
enums::v1::ArchivalState,
|
|
@@ -32,9 +33,8 @@ use crate::{
|
|
|
32
33
|
workflow_handle::UntypedWorkflowHandle,
|
|
33
34
|
};
|
|
34
35
|
use backoff::{exponential, ExponentialBackoff, SystemClock};
|
|
35
|
-
use http::uri::InvalidUri;
|
|
36
|
+
use http::{uri::InvalidUri, Uri};
|
|
36
37
|
use once_cell::sync::OnceCell;
|
|
37
|
-
use opentelemetry::metrics::Meter;
|
|
38
38
|
use parking_lot::RwLock;
|
|
39
39
|
use std::{
|
|
40
40
|
collections::HashMap,
|
|
@@ -114,6 +114,14 @@ pub struct ClientOptions {
|
|
|
114
114
|
/// Retry configuration for the server client. Default is [RetryConfig::default]
|
|
115
115
|
#[builder(default)]
|
|
116
116
|
pub retry_config: RetryConfig,
|
|
117
|
+
|
|
118
|
+
/// If set, override the origin used when connecting. May be useful in rare situations where tls
|
|
119
|
+
/// verification needs to use a different name from what should be set as the `:authority`
|
|
120
|
+
/// header. If [TlsConfig::domain] is set, and this is not, this will be set to
|
|
121
|
+
/// `https://<domain>`, effectively making the `:authority` header consistent with the domain
|
|
122
|
+
/// override.
|
|
123
|
+
#[builder(default)]
|
|
124
|
+
pub override_origin: Option<Uri>,
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
/// Configuration options for TLS
|
|
@@ -286,7 +294,7 @@ impl ClientOptions {
|
|
|
286
294
|
pub async fn connect(
|
|
287
295
|
&self,
|
|
288
296
|
namespace: impl Into<String>,
|
|
289
|
-
metrics_meter: Option<&
|
|
297
|
+
metrics_meter: Option<&dyn ClientMetricProvider>,
|
|
290
298
|
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
|
291
299
|
) -> Result<RetryClient<Client>, ClientInitError> {
|
|
292
300
|
let client = self
|
|
@@ -304,12 +312,17 @@ impl ClientOptions {
|
|
|
304
312
|
/// See [RetryClient] for more
|
|
305
313
|
pub async fn connect_no_namespace(
|
|
306
314
|
&self,
|
|
307
|
-
metrics_meter: Option<&
|
|
315
|
+
metrics_meter: Option<&dyn ClientMetricProvider>,
|
|
308
316
|
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
|
309
317
|
) -> Result<RetryClient<ConfiguredClient<TemporalServiceClientWithMetrics>>, ClientInitError>
|
|
310
318
|
{
|
|
311
319
|
let channel = Channel::from_shared(self.target_url.to_string())?;
|
|
312
320
|
let channel = self.add_tls_to_channel(channel).await?;
|
|
321
|
+
let channel = if let Some(origin) = self.override_origin.clone() {
|
|
322
|
+
channel.origin(origin)
|
|
323
|
+
} else {
|
|
324
|
+
channel
|
|
325
|
+
};
|
|
313
326
|
let channel = channel.connect().await?;
|
|
314
327
|
let service = ServiceBuilder::new()
|
|
315
328
|
.layer_fn(|channel| GrpcMetricSvc {
|
|
@@ -347,10 +360,7 @@ impl ClientOptions {
|
|
|
347
360
|
|
|
348
361
|
/// If TLS is configured, set the appropriate options on the provided channel and return it.
|
|
349
362
|
/// Passes it through if TLS options not set.
|
|
350
|
-
async fn add_tls_to_channel(
|
|
351
|
-
&self,
|
|
352
|
-
channel: Endpoint,
|
|
353
|
-
) -> Result<Endpoint, tonic::transport::Error> {
|
|
363
|
+
async fn add_tls_to_channel(&self, mut channel: Endpoint) -> Result<Endpoint, ClientInitError> {
|
|
354
364
|
if let Some(tls_cfg) = &self.tls_cfg {
|
|
355
365
|
let mut tls = tonic::transport::ClientTlsConfig::new();
|
|
356
366
|
|
|
@@ -361,6 +371,13 @@ impl ClientOptions {
|
|
|
361
371
|
|
|
362
372
|
if let Some(domain) = &tls_cfg.domain {
|
|
363
373
|
tls = tls.domain_name(domain);
|
|
374
|
+
|
|
375
|
+
// This song and dance ultimately is just to make sure the `:authority` header ends
|
|
376
|
+
// up correct on requests while we use TLS. Setting the header directly in our
|
|
377
|
+
// interceptor doesn't work since seemingly it is overridden at some point by
|
|
378
|
+
// something lower level.
|
|
379
|
+
let uri: Uri = format!("https://{}", domain).parse()?;
|
|
380
|
+
channel = channel.origin(uri);
|
|
364
381
|
}
|
|
365
382
|
|
|
366
383
|
if let Some(client_opts) = &tls_cfg.client_tls_config {
|
|
@@ -369,7 +386,7 @@ impl ClientOptions {
|
|
|
369
386
|
tls = tls.identity(client_identity);
|
|
370
387
|
}
|
|
371
388
|
|
|
372
|
-
return channel.tls_config(tls);
|
|
389
|
+
return channel.tls_config(tls).map_err(Into::into);
|
|
373
390
|
}
|
|
374
391
|
Ok(channel)
|
|
375
392
|
}
|
|
@@ -1077,6 +1094,7 @@ impl WorkflowClientTrait for Client {
|
|
|
1077
1094
|
identity: self.inner.options.identity.clone(),
|
|
1078
1095
|
binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
|
|
1079
1096
|
namespace: self.namespace.clone(),
|
|
1097
|
+
messages: vec![],
|
|
1080
1098
|
};
|
|
1081
1099
|
Ok(self
|
|
1082
1100
|
.wf_svc()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use crate::{AttachMetricLabels, LONG_POLL_METHOD_NAMES};
|
|
2
2
|
use futures::{future::BoxFuture, FutureExt};
|
|
3
3
|
use opentelemetry::{
|
|
4
|
-
metrics::{Counter, Histogram
|
|
4
|
+
metrics::{Counter, Histogram},
|
|
5
5
|
KeyValue,
|
|
6
6
|
};
|
|
7
7
|
use std::{
|
|
@@ -30,18 +30,27 @@ pub struct MetricsContext {
|
|
|
30
30
|
long_svc_request_latency: Histogram<u64>,
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/// Things that can provide metrics for the client implement this. Trait exists to avoid having
|
|
34
|
+
/// to make a whole new lower-level crate just for a tiny shared wrapper around OTel meters.
|
|
35
|
+
pub trait ClientMetricProvider: Send + Sync {
|
|
36
|
+
/// Construct a counter metric
|
|
37
|
+
fn counter(&self, name: &'static str) -> Counter<u64>;
|
|
38
|
+
/// Construct a histogram metric
|
|
39
|
+
fn histogram(&self, name: &'static str) -> Histogram<u64>;
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
impl MetricsContext {
|
|
34
|
-
pub(crate) fn new(kvs: Vec<KeyValue>,
|
|
43
|
+
pub(crate) fn new(kvs: Vec<KeyValue>, metric_provider: &dyn ClientMetricProvider) -> Self {
|
|
35
44
|
Self {
|
|
36
45
|
ctx: opentelemetry::Context::current(),
|
|
37
46
|
kvs: Arc::new(kvs),
|
|
38
47
|
poll_is_long: false,
|
|
39
|
-
svc_request:
|
|
40
|
-
svc_request_failed:
|
|
41
|
-
long_svc_request:
|
|
42
|
-
long_svc_request_failed:
|
|
43
|
-
svc_request_latency:
|
|
44
|
-
long_svc_request_latency:
|
|
48
|
+
svc_request: metric_provider.counter("request"),
|
|
49
|
+
svc_request_failed: metric_provider.counter("request_failure"),
|
|
50
|
+
long_svc_request: metric_provider.counter("long_request"),
|
|
51
|
+
long_svc_request_failed: metric_provider.counter("long_request_failure"),
|
|
52
|
+
svc_request_latency: metric_provider.histogram("request_latency"),
|
|
53
|
+
long_svc_request_latency: metric_provider.histogram("long_request_latency"),
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
|
|
@@ -760,9 +760,9 @@ proxier! {
|
|
|
760
760
|
}
|
|
761
761
|
);
|
|
762
762
|
(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
763
|
+
update_workflow_execution,
|
|
764
|
+
UpdateWorkflowExecutionRequest,
|
|
765
|
+
UpdateWorkflowExecutionResponse,
|
|
766
766
|
|r| {
|
|
767
767
|
let labels = AttachMetricLabels::namespace(r.get_ref().namespace.clone());
|
|
768
768
|
r.extensions_mut().insert(labels);
|
package/sdk-core/core/Cargo.toml
CHANGED
|
@@ -21,7 +21,6 @@ save_wf_inputs = ["rmp-serde", "temporal-sdk-core-protos/serde_serialize"]
|
|
|
21
21
|
[dependencies]
|
|
22
22
|
anyhow = "1.0"
|
|
23
23
|
arc-swap = "1.3"
|
|
24
|
-
async-channel = "1.6"
|
|
25
24
|
async-trait = "0.1"
|
|
26
25
|
base64 = "0.21"
|
|
27
26
|
crossbeam = "0.8"
|
|
@@ -37,7 +36,7 @@ http = "0.2"
|
|
|
37
36
|
hyper = "0.14"
|
|
38
37
|
itertools = "0.10"
|
|
39
38
|
lazy_static = "1.4"
|
|
40
|
-
lru = "0.
|
|
39
|
+
lru = "0.10"
|
|
41
40
|
mockall = "0.11"
|
|
42
41
|
nix = "0.26"
|
|
43
42
|
once_cell = "1.5"
|
|
@@ -59,7 +58,7 @@ siphasher = "0.3"
|
|
|
59
58
|
slotmap = "1.0"
|
|
60
59
|
tar = "0.4"
|
|
61
60
|
thiserror = "1.0"
|
|
62
|
-
tokio = { version = "1.
|
|
61
|
+
tokio = { version = "1.26", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs", "process"] }
|
|
63
62
|
tokio-util = { version = "0.7", features = ["io", "io-util"] }
|
|
64
63
|
tokio-stream = "0.1"
|
|
65
64
|
tonic = { version = "0.8", features = ["tls", "tls-roots"] }
|
|
@@ -94,7 +93,7 @@ assert_matches = "1.4"
|
|
|
94
93
|
bimap = "0.6.1"
|
|
95
94
|
clap = { version = "4.0", features = ["derive"] }
|
|
96
95
|
criterion = "0.4"
|
|
97
|
-
rstest = "0.
|
|
96
|
+
rstest = "0.17"
|
|
98
97
|
temporal-sdk-core-test-utils = { path = "../test-utils" }
|
|
99
98
|
temporal-sdk = { path = "../sdk" }
|
|
100
99
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
use parking_lot::Mutex;
|
|
2
|
+
use std::sync::atomic::{AtomicBool, Ordering};
|
|
3
|
+
|
|
4
|
+
/// Implements something a bit like a `OnceCell`, but starts already initialized and allows you
|
|
5
|
+
/// to take everything out of it only once in a thread-safe way. This isn't optimized for super
|
|
6
|
+
/// fast-path usage.
|
|
7
|
+
pub struct TakeCell<T> {
|
|
8
|
+
taken: AtomicBool,
|
|
9
|
+
data: Mutex<Option<T>>,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
impl<T> TakeCell<T> {
|
|
13
|
+
pub fn new(val: T) -> Self {
|
|
14
|
+
Self {
|
|
15
|
+
taken: AtomicBool::new(false),
|
|
16
|
+
data: Mutex::new(Some(val)),
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/// If the cell has not already been taken from, takes the value and returns it
|
|
21
|
+
pub fn take_once(&self) -> Option<T> {
|
|
22
|
+
if self.taken.load(Ordering::Acquire) {
|
|
23
|
+
return None;
|
|
24
|
+
}
|
|
25
|
+
self.taken.store(true, Ordering::Release);
|
|
26
|
+
self.data.lock().take()
|
|
27
|
+
}
|
|
28
|
+
}
|