@temporalio/core-bridge 1.8.5 → 1.9.0-rc.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 +189 -152
- package/Cargo.toml +1 -0
- package/lib/index.d.ts +17 -44
- package/lib/index.js.map +1 -1
- package/package.json +3 -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/heavy.yml +4 -0
- package/sdk-core/.github/workflows/per-pr.yml +96 -0
- package/sdk-core/ARCHITECTURE.md +1 -1
- package/sdk-core/Cargo.toml +6 -0
- package/sdk-core/README.md +37 -21
- package/sdk-core/client/Cargo.toml +6 -3
- package/sdk-core/client/src/lib.rs +272 -138
- package/sdk-core/client/src/metrics.rs +68 -57
- package/sdk-core/client/src/raw.rs +191 -45
- package/sdk-core/client/src/retry.rs +20 -0
- package/sdk-core/client/src/worker_registry/mod.rs +264 -0
- package/sdk-core/client/src/workflow_handle/mod.rs +2 -1
- package/sdk-core/core/Cargo.toml +16 -18
- package/sdk-core/core/src/core_tests/child_workflows.rs +7 -7
- package/sdk-core/core/src/core_tests/mod.rs +1 -0
- package/sdk-core/core/src/core_tests/replay_flag.rs +29 -39
- package/sdk-core/core/src/core_tests/updates.rs +73 -0
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +52 -1
- package/sdk-core/core/src/ephemeral_server/mod.rs +34 -11
- package/sdk-core/core/src/internal_flags.rs +7 -1
- package/sdk-core/core/src/lib.rs +19 -36
- package/sdk-core/core/src/protosext/mod.rs +11 -3
- package/sdk-core/core/src/protosext/protocol_messages.rs +102 -0
- package/sdk-core/core/src/replay/mod.rs +100 -48
- package/sdk-core/core/src/telemetry/log_export.rs +161 -28
- package/sdk-core/core/src/telemetry/metrics.rs +869 -248
- package/sdk-core/core/src/telemetry/mod.rs +135 -239
- package/sdk-core/core/src/telemetry/prometheus_server.rs +36 -31
- package/sdk-core/core/src/test_help/mod.rs +63 -4
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +12 -2
- package/sdk-core/core/src/worker/activities.rs +276 -10
- package/sdk-core/core/src/worker/client/mocks.rs +18 -0
- package/sdk-core/core/src/worker/client.rs +16 -3
- package/sdk-core/core/src/worker/mod.rs +50 -19
- package/sdk-core/core/src/worker/slot_provider.rs +175 -0
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +27 -34
- package/sdk-core/core/src/worker/workflow/history_update.rs +4 -1
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +36 -94
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +34 -22
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +50 -34
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +106 -92
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +22 -21
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +386 -499
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +12 -2
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +33 -26
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +198 -215
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +66 -62
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +88 -119
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +3 -1
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +411 -0
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +26 -25
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +302 -85
- package/sdk-core/core/src/worker/workflow/managed_run.rs +179 -132
- package/sdk-core/core/src/worker/workflow/mod.rs +121 -46
- package/sdk-core/core/src/worker/workflow/run_cache.rs +8 -12
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +45 -38
- package/sdk-core/core-api/Cargo.toml +7 -6
- package/sdk-core/core-api/src/lib.rs +4 -12
- package/sdk-core/core-api/src/telemetry/metrics.rs +334 -0
- package/sdk-core/core-api/src/telemetry.rs +53 -42
- package/sdk-core/core-api/src/worker.rs +7 -0
- package/sdk-core/{.buildkite/docker → docker}/docker-compose.yaml +1 -1
- package/sdk-core/etc/dynamic-config.yaml +11 -1
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +1 -3
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +2 -2
- package/sdk-core/sdk/Cargo.toml +1 -1
- package/sdk-core/sdk/src/lib.rs +85 -7
- package/sdk-core/sdk/src/workflow_context/options.rs +4 -0
- package/sdk-core/sdk/src/workflow_context.rs +43 -15
- package/sdk-core/sdk/src/workflow_future.rs +334 -204
- package/sdk-core/sdk-core-protos/Cargo.toml +2 -2
- package/sdk-core/sdk-core-protos/build.rs +14 -14
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/Dockerfile +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +99 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/api-linter.yaml +56 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.gen.yaml +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.lock +11 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +18 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/api/annotations.proto +31 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/api/http.proto +379 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/any.proto +162 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/descriptor.proto +1212 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/duration.proto +115 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/empty.proto +51 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/timestamp.proto +144 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/wrappers.proto +123 -0
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/batch/v1/message.proto +3 -5
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/command/v1/message.proto +11 -13
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/common/v1/message.proto +2 -4
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/reset.proto +1 -1
- package/sdk-core/{protos/api_upstream/build/tools.go → sdk-core-protos/protos/api_upstream/temporal/api/export/v1/message.proto} +22 -6
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/filter/v1/message.proto +2 -4
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/history/v1/message.proto +21 -23
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/namespace/v1/message.proto +2 -4
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/operatorservice/v1/request_response.proto +2 -0
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/operatorservice/v1/service.proto +4 -0
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/replication/v1/message.proto +1 -3
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/schedule/v1/message.proto +36 -20
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +13 -0
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -4
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/update/v1/message.proto +1 -1
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/version/v1/message.proto +2 -3
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/workflow/v1/message.proto +18 -20
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/workflowservice/v1/request_response.proto +84 -32
- package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/workflowservice/v1/service.proto +205 -47
- package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +57 -0
- package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +27 -0
- package/sdk-core/sdk-core-protos/src/history_builder.rs +67 -2
- package/sdk-core/sdk-core-protos/src/lib.rs +75 -2
- package/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
- package/sdk-core/test-utils/Cargo.toml +5 -1
- package/sdk-core/test-utils/src/canned_histories.rs +3 -57
- package/sdk-core/test-utils/src/interceptors.rs +46 -0
- package/sdk-core/test-utils/src/lib.rs +106 -38
- package/sdk-core/tests/integ_tests/metrics_tests.rs +110 -15
- package/sdk-core/tests/integ_tests/queries_tests.rs +174 -3
- package/sdk-core/tests/integ_tests/update_tests.rs +908 -0
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +44 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +4 -4
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +61 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +27 -2
- package/sdk-core/tests/integ_tests/workflow_tests.rs +1 -0
- package/sdk-core/tests/main.rs +2 -1
- package/sdk-core/tests/runner.rs +15 -2
- package/src/conversions.rs +75 -89
- package/src/helpers.rs +74 -0
- package/src/runtime.rs +17 -6
- package/src/worker.rs +14 -61
- package/ts/index.ts +21 -52
- package/sdk-core/.buildkite/docker/Dockerfile +0 -9
- package/sdk-core/.buildkite/docker/build.sh +0 -5
- package/sdk-core/.buildkite/docker/docker-compose-ci.yaml +0 -27
- package/sdk-core/.buildkite/pipeline.yml +0 -57
- package/sdk-core/.github/workflows/semgrep.yml +0 -25
- package/sdk-core/core/src/worker/workflow/bridge.rs +0 -35
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +0 -215
- package/sdk-core/protos/api_upstream/.buildkite/Dockerfile +0 -2
- package/sdk-core/protos/api_upstream/Makefile +0 -80
- package/sdk-core/protos/api_upstream/api-linter.yaml +0 -40
- package/sdk-core/protos/api_upstream/buf.yaml +0 -9
- package/sdk-core/protos/api_upstream/build/go.mod +0 -7
- package/sdk-core/protos/api_upstream/build/go.sum +0 -5
- package/sdk-core/protos/api_upstream/go.mod +0 -6
- package/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +0 -141
- /package/sdk-core/{.buildkite/docker → docker}/docker-compose-telem.yaml +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/.buildkite/docker-compose.yml +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/.buildkite/pipeline.yml +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/.github/CODEOWNERS +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/.github/workflows/publish-docs.yml +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/LICENSE +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/README.md +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/common.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/query.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/update.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/failure/v1/message.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/api_upstream/temporal/api/query/v1/message.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/google/rpc/status.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/grpc/health/v1/health.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/common/common.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/core_interface.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/external_data/external_data.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/testsrv_upstream/Makefile +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/testsrv_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/testsrv_upstream/buf.yaml +0 -0
- /package/sdk-core/{protos/api_upstream → sdk-core-protos/protos/testsrv_upstream}/dependencies/gogoproto/gogo.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
- /package/sdk-core/{protos → sdk-core-protos/protos}/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
|
@@ -1,69 +1,81 @@
|
|
|
1
1
|
use crate::{AttachMetricLabels, LONG_POLL_METHOD_NAMES};
|
|
2
2
|
use futures::{future::BoxFuture, FutureExt};
|
|
3
|
-
use opentelemetry::{
|
|
4
|
-
metrics::{Counter, Histogram},
|
|
5
|
-
KeyValue,
|
|
6
|
-
};
|
|
7
3
|
use std::{
|
|
8
4
|
sync::Arc,
|
|
9
5
|
task::{Context, Poll},
|
|
10
6
|
time::{Duration, Instant},
|
|
11
7
|
};
|
|
8
|
+
use temporal_sdk_core_api::telemetry::metrics::{
|
|
9
|
+
CoreMeter, Counter, Histogram, MetricAttributes, MetricKeyValue, MetricParameters,
|
|
10
|
+
TemporalMeter,
|
|
11
|
+
};
|
|
12
12
|
use tonic::{body::BoxBody, transport::Channel};
|
|
13
13
|
use tower::Service;
|
|
14
14
|
|
|
15
15
|
/// Used to track context associated with metrics, and record/update them
|
|
16
16
|
// Possible improvement: make generic over some type tag so that methods are only exposed if the
|
|
17
17
|
// appropriate k/vs have already been set.
|
|
18
|
-
#[derive(Clone,
|
|
18
|
+
#[derive(Clone, derive_more::DebugCustom)]
|
|
19
|
+
#[debug(fmt = "MetricsContext {{ attribs: {kvs:?}, poll_is_long: {poll_is_long} }}")]
|
|
19
20
|
pub struct MetricsContext {
|
|
20
|
-
|
|
21
|
-
kvs:
|
|
21
|
+
meter: Arc<dyn CoreMeter>,
|
|
22
|
+
kvs: MetricAttributes,
|
|
22
23
|
poll_is_long: bool,
|
|
23
24
|
|
|
24
|
-
svc_request: Counter
|
|
25
|
-
svc_request_failed: Counter
|
|
26
|
-
long_svc_request: Counter
|
|
27
|
-
long_svc_request_failed: Counter
|
|
28
|
-
|
|
29
|
-
svc_request_latency: Histogram<u64>,
|
|
30
|
-
long_svc_request_latency: Histogram<u64>,
|
|
31
|
-
}
|
|
25
|
+
svc_request: Arc<dyn Counter>,
|
|
26
|
+
svc_request_failed: Arc<dyn Counter>,
|
|
27
|
+
long_svc_request: Arc<dyn Counter>,
|
|
28
|
+
long_svc_request_failed: Arc<dyn Counter>,
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
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>;
|
|
30
|
+
svc_request_latency: Arc<dyn Histogram>,
|
|
31
|
+
long_svc_request_latency: Arc<dyn Histogram>,
|
|
40
32
|
}
|
|
41
33
|
|
|
42
34
|
impl MetricsContext {
|
|
43
|
-
pub(crate) fn new(
|
|
35
|
+
pub(crate) fn new(tm: TemporalMeter) -> Self {
|
|
36
|
+
let meter = tm.inner;
|
|
44
37
|
Self {
|
|
45
|
-
|
|
46
|
-
kvs: Arc::new(kvs),
|
|
38
|
+
kvs: meter.new_attributes(tm.default_attribs),
|
|
47
39
|
poll_is_long: false,
|
|
48
|
-
svc_request:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
svc_request: meter.counter(MetricParameters {
|
|
41
|
+
name: "request".into(),
|
|
42
|
+
description: "Count of client request successes by rpc name".into(),
|
|
43
|
+
unit: "".into(),
|
|
44
|
+
}),
|
|
45
|
+
svc_request_failed: meter.counter(MetricParameters {
|
|
46
|
+
name: "request_failure".into(),
|
|
47
|
+
description: "Count of client request failures by rpc name".into(),
|
|
48
|
+
unit: "".into(),
|
|
49
|
+
}),
|
|
50
|
+
long_svc_request: meter.counter(MetricParameters {
|
|
51
|
+
name: "long_request".into(),
|
|
52
|
+
description: "Count of long-poll request successes by rpc name".into(),
|
|
53
|
+
unit: "".into(),
|
|
54
|
+
}),
|
|
55
|
+
long_svc_request_failed: meter.counter(MetricParameters {
|
|
56
|
+
name: "long_request_failure".into(),
|
|
57
|
+
description: "Count of long-poll request failures by rpc name".into(),
|
|
58
|
+
unit: "".into(),
|
|
59
|
+
}),
|
|
60
|
+
svc_request_latency: meter.histogram(MetricParameters {
|
|
61
|
+
name: "request_latency".into(),
|
|
62
|
+
unit: "ms".into(),
|
|
63
|
+
description: "Histogram of client request latencies".into(),
|
|
64
|
+
}),
|
|
65
|
+
long_svc_request_latency: meter.histogram(MetricParameters {
|
|
66
|
+
name: "long_request_latency".into(),
|
|
67
|
+
unit: "ms".into(),
|
|
68
|
+
description: "Histogram of client long-poll request latencies".into(),
|
|
69
|
+
}),
|
|
70
|
+
meter,
|
|
54
71
|
}
|
|
55
72
|
}
|
|
56
73
|
|
|
57
|
-
///
|
|
58
|
-
pub(crate) fn with_new_attrs(&self, new_kvs: impl IntoIterator<Item =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// Add new attributes to the context, mutating it
|
|
65
|
-
pub(crate) fn add_new_attrs(&mut self, new_kvs: impl IntoIterator<Item = KeyValue>) {
|
|
66
|
-
Arc::make_mut(&mut self.kvs).extend(new_kvs);
|
|
74
|
+
/// Mutate this metrics context with new attributes
|
|
75
|
+
pub(crate) fn with_new_attrs(&mut self, new_kvs: impl IntoIterator<Item = MetricKeyValue>) {
|
|
76
|
+
self.kvs = self
|
|
77
|
+
.meter
|
|
78
|
+
.extend_attributes(self.kvs.clone(), new_kvs.into());
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
pub(crate) fn set_is_long_poll(&mut self) {
|
|
@@ -73,18 +85,18 @@ impl MetricsContext {
|
|
|
73
85
|
/// A request to the temporal service was made
|
|
74
86
|
pub(crate) fn svc_request(&self) {
|
|
75
87
|
if self.poll_is_long {
|
|
76
|
-
self.long_svc_request.add(
|
|
88
|
+
self.long_svc_request.add(1, &self.kvs);
|
|
77
89
|
} else {
|
|
78
|
-
self.svc_request.add(
|
|
90
|
+
self.svc_request.add(1, &self.kvs);
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
/// A request to the temporal service failed
|
|
83
95
|
pub(crate) fn svc_request_failed(&self) {
|
|
84
96
|
if self.poll_is_long {
|
|
85
|
-
self.long_svc_request_failed.add(
|
|
97
|
+
self.long_svc_request_failed.add(1, &self.kvs);
|
|
86
98
|
} else {
|
|
87
|
-
self.svc_request_failed.add(
|
|
99
|
+
self.svc_request_failed.add(1, &self.kvs);
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
|
|
@@ -92,10 +104,10 @@ impl MetricsContext {
|
|
|
92
104
|
pub(crate) fn record_svc_req_latency(&self, dur: Duration) {
|
|
93
105
|
if self.poll_is_long {
|
|
94
106
|
self.long_svc_request_latency
|
|
95
|
-
.record(
|
|
107
|
+
.record(dur.as_millis() as u64, &self.kvs);
|
|
96
108
|
} else {
|
|
97
109
|
self.svc_request_latency
|
|
98
|
-
.record(
|
|
110
|
+
.record(dur.as_millis() as u64, &self.kvs);
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
113
|
}
|
|
@@ -104,16 +116,16 @@ const KEY_NAMESPACE: &str = "namespace";
|
|
|
104
116
|
const KEY_SVC_METHOD: &str = "operation";
|
|
105
117
|
const KEY_TASK_QUEUE: &str = "task_queue";
|
|
106
118
|
|
|
107
|
-
pub(crate) fn namespace_kv(ns: String) ->
|
|
108
|
-
|
|
119
|
+
pub(crate) fn namespace_kv(ns: String) -> MetricKeyValue {
|
|
120
|
+
MetricKeyValue::new(KEY_NAMESPACE, ns)
|
|
109
121
|
}
|
|
110
122
|
|
|
111
|
-
pub(crate) fn task_queue_kv(tq: String) ->
|
|
112
|
-
|
|
123
|
+
pub(crate) fn task_queue_kv(tq: String) -> MetricKeyValue {
|
|
124
|
+
MetricKeyValue::new(KEY_TASK_QUEUE, tq)
|
|
113
125
|
}
|
|
114
126
|
|
|
115
|
-
pub(crate) fn svc_operation(op: String) ->
|
|
116
|
-
|
|
127
|
+
pub(crate) fn svc_operation(op: String) -> MetricKeyValue {
|
|
128
|
+
MetricKeyValue::new(KEY_SVC_METHOD, op)
|
|
117
129
|
}
|
|
118
130
|
|
|
119
131
|
/// Implements metrics functionality for gRPC (really, any http) calls
|
|
@@ -137,19 +149,18 @@ impl Service<http::Request<BoxBody>> for GrpcMetricSvc {
|
|
|
137
149
|
let metrics = self
|
|
138
150
|
.metrics
|
|
139
151
|
.clone()
|
|
140
|
-
.map(|m| {
|
|
152
|
+
.map(|mut m| {
|
|
141
153
|
// Attach labels from client wrapper
|
|
142
154
|
if let Some(other_labels) = req.extensions_mut().remove::<AttachMetricLabels>() {
|
|
143
155
|
m.with_new_attrs(other_labels.labels)
|
|
144
|
-
} else {
|
|
145
|
-
m
|
|
146
156
|
}
|
|
157
|
+
m
|
|
147
158
|
})
|
|
148
159
|
.and_then(|mut metrics| {
|
|
149
160
|
// Attach method name label if possible
|
|
150
161
|
req.uri().to_string().rsplit_once('/').map(|split_tup| {
|
|
151
162
|
let method_name = split_tup.1;
|
|
152
|
-
metrics.
|
|
163
|
+
metrics.with_new_attrs([svc_operation(method_name.to_string())]);
|
|
153
164
|
if LONG_POLL_METHOD_NAMES.contains(&method_name) {
|
|
154
165
|
metrics.set_is_long_poll();
|
|
155
166
|
}
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
use crate::{
|
|
6
6
|
metrics::{namespace_kv, task_queue_kv},
|
|
7
7
|
raw::sealed::RawClientLike,
|
|
8
|
+
worker_registry::{Slot, SlotManager},
|
|
8
9
|
Client, ConfiguredClient, InterceptedMetricsSvc, RetryClient, TemporalServiceClient,
|
|
9
10
|
LONG_POLL_TIMEOUT,
|
|
10
11
|
};
|
|
11
12
|
use futures::{future::BoxFuture, FutureExt, TryFutureExt};
|
|
13
|
+
use std::sync::Arc;
|
|
14
|
+
use temporal_sdk_core_api::telemetry::metrics::MetricKeyValue;
|
|
12
15
|
use temporal_sdk_core_protos::{
|
|
13
16
|
grpc::health::v1::{health_client::HealthClient, *},
|
|
14
17
|
temporal::api::{
|
|
@@ -25,22 +28,37 @@ use tonic::{
|
|
|
25
28
|
pub(super) mod sealed {
|
|
26
29
|
use super::*;
|
|
27
30
|
|
|
28
|
-
/// Something that has
|
|
31
|
+
/// Something that has access to the raw grpc services
|
|
29
32
|
#[async_trait::async_trait]
|
|
30
33
|
pub trait RawClientLike: Send {
|
|
31
34
|
type SvcType: Send + Sync + Clone + 'static;
|
|
32
35
|
|
|
33
|
-
/// Return the workflow service client instance
|
|
34
|
-
fn workflow_client(&
|
|
36
|
+
/// Return a ref to the workflow service client instance
|
|
37
|
+
fn workflow_client(&self) -> &WorkflowServiceClient<Self::SvcType>;
|
|
35
38
|
|
|
36
|
-
/// Return the
|
|
37
|
-
fn
|
|
39
|
+
/// Return a mutable ref to the workflow service client instance
|
|
40
|
+
fn workflow_client_mut(&mut self) -> &mut WorkflowServiceClient<Self::SvcType>;
|
|
38
41
|
|
|
39
|
-
/// Return the
|
|
40
|
-
fn
|
|
42
|
+
/// Return a ref to the operator service client instance
|
|
43
|
+
fn operator_client(&self) -> &OperatorServiceClient<Self::SvcType>;
|
|
41
44
|
|
|
42
|
-
/// Return the
|
|
43
|
-
fn
|
|
45
|
+
/// Return a mutable ref to the operator service client instance
|
|
46
|
+
fn operator_client_mut(&mut self) -> &mut OperatorServiceClient<Self::SvcType>;
|
|
47
|
+
|
|
48
|
+
/// Return a ref to the test service client instance
|
|
49
|
+
fn test_client(&self) -> &TestServiceClient<Self::SvcType>;
|
|
50
|
+
|
|
51
|
+
/// Return a mutable ref to the test service client instance
|
|
52
|
+
fn test_client_mut(&mut self) -> &mut TestServiceClient<Self::SvcType>;
|
|
53
|
+
|
|
54
|
+
/// Return a ref to the health service client instance
|
|
55
|
+
fn health_client(&self) -> &HealthClient<Self::SvcType>;
|
|
56
|
+
|
|
57
|
+
/// Return a mutable ref to the health service client instance
|
|
58
|
+
fn health_client_mut(&mut self) -> &mut HealthClient<Self::SvcType>;
|
|
59
|
+
|
|
60
|
+
/// Return a registry with workers using this client instance
|
|
61
|
+
fn get_workers_info(&self) -> Option<Arc<SlotManager>>;
|
|
44
62
|
|
|
45
63
|
async fn call<F, Req, Resp>(
|
|
46
64
|
&mut self,
|
|
@@ -58,7 +76,6 @@ pub(super) mod sealed {
|
|
|
58
76
|
}
|
|
59
77
|
}
|
|
60
78
|
|
|
61
|
-
// Here we implement retry on anything that is already RawClientLike
|
|
62
79
|
#[async_trait::async_trait]
|
|
63
80
|
impl<RC, T> RawClientLike for RetryClient<RC>
|
|
64
81
|
where
|
|
@@ -67,20 +84,40 @@ where
|
|
|
67
84
|
{
|
|
68
85
|
type SvcType = T;
|
|
69
86
|
|
|
70
|
-
fn workflow_client(&
|
|
71
|
-
self.
|
|
87
|
+
fn workflow_client(&self) -> &WorkflowServiceClient<Self::SvcType> {
|
|
88
|
+
self.get_client().workflow_client()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fn workflow_client_mut(&mut self) -> &mut WorkflowServiceClient<Self::SvcType> {
|
|
92
|
+
self.get_client_mut().workflow_client_mut()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
fn operator_client(&self) -> &OperatorServiceClient<Self::SvcType> {
|
|
96
|
+
self.get_client().operator_client()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fn operator_client_mut(&mut self) -> &mut OperatorServiceClient<Self::SvcType> {
|
|
100
|
+
self.get_client_mut().operator_client_mut()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fn test_client(&self) -> &TestServiceClient<Self::SvcType> {
|
|
104
|
+
self.get_client().test_client()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
fn test_client_mut(&mut self) -> &mut TestServiceClient<Self::SvcType> {
|
|
108
|
+
self.get_client_mut().test_client_mut()
|
|
72
109
|
}
|
|
73
110
|
|
|
74
|
-
fn
|
|
75
|
-
self.
|
|
111
|
+
fn health_client(&self) -> &HealthClient<Self::SvcType> {
|
|
112
|
+
self.get_client().health_client()
|
|
76
113
|
}
|
|
77
114
|
|
|
78
|
-
fn
|
|
79
|
-
self.get_client_mut().
|
|
115
|
+
fn health_client_mut(&mut self) -> &mut HealthClient<Self::SvcType> {
|
|
116
|
+
self.get_client_mut().health_client_mut()
|
|
80
117
|
}
|
|
81
118
|
|
|
82
|
-
fn
|
|
83
|
-
self.
|
|
119
|
+
fn get_workers_info(&self) -> Option<Arc<SlotManager>> {
|
|
120
|
+
self.get_client().get_workers_info()
|
|
84
121
|
}
|
|
85
122
|
|
|
86
123
|
async fn call<F, Req, Resp>(
|
|
@@ -114,21 +151,41 @@ where
|
|
|
114
151
|
{
|
|
115
152
|
type SvcType = T;
|
|
116
153
|
|
|
117
|
-
fn workflow_client(&
|
|
154
|
+
fn workflow_client(&self) -> &WorkflowServiceClient<Self::SvcType> {
|
|
155
|
+
self.workflow_svc()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
fn workflow_client_mut(&mut self) -> &mut WorkflowServiceClient<Self::SvcType> {
|
|
118
159
|
self.workflow_svc_mut()
|
|
119
160
|
}
|
|
120
161
|
|
|
121
|
-
fn operator_client(&
|
|
162
|
+
fn operator_client(&self) -> &OperatorServiceClient<Self::SvcType> {
|
|
163
|
+
self.operator_svc()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fn operator_client_mut(&mut self) -> &mut OperatorServiceClient<Self::SvcType> {
|
|
122
167
|
self.operator_svc_mut()
|
|
123
168
|
}
|
|
124
169
|
|
|
125
|
-
fn test_client(&
|
|
170
|
+
fn test_client(&self) -> &TestServiceClient<Self::SvcType> {
|
|
171
|
+
self.test_svc()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fn test_client_mut(&mut self) -> &mut TestServiceClient<Self::SvcType> {
|
|
126
175
|
self.test_svc_mut()
|
|
127
176
|
}
|
|
128
177
|
|
|
129
|
-
fn health_client(&
|
|
178
|
+
fn health_client(&self) -> &HealthClient<Self::SvcType> {
|
|
179
|
+
self.health_svc()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fn health_client_mut(&mut self) -> &mut HealthClient<Self::SvcType> {
|
|
130
183
|
self.health_svc_mut()
|
|
131
184
|
}
|
|
185
|
+
|
|
186
|
+
fn get_workers_info(&self) -> Option<Arc<SlotManager>> {
|
|
187
|
+
None
|
|
188
|
+
}
|
|
132
189
|
}
|
|
133
190
|
|
|
134
191
|
impl<T> RawClientLike for ConfiguredClient<TemporalServiceClient<T>>
|
|
@@ -141,41 +198,81 @@ where
|
|
|
141
198
|
{
|
|
142
199
|
type SvcType = T;
|
|
143
200
|
|
|
144
|
-
fn workflow_client(&
|
|
201
|
+
fn workflow_client(&self) -> &WorkflowServiceClient<Self::SvcType> {
|
|
145
202
|
self.client.workflow_client()
|
|
146
203
|
}
|
|
147
204
|
|
|
148
|
-
fn
|
|
205
|
+
fn workflow_client_mut(&mut self) -> &mut WorkflowServiceClient<Self::SvcType> {
|
|
206
|
+
self.client.workflow_client_mut()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
fn operator_client(&self) -> &OperatorServiceClient<Self::SvcType> {
|
|
149
210
|
self.client.operator_client()
|
|
150
211
|
}
|
|
151
212
|
|
|
152
|
-
fn
|
|
213
|
+
fn operator_client_mut(&mut self) -> &mut OperatorServiceClient<Self::SvcType> {
|
|
214
|
+
self.client.operator_client_mut()
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fn test_client(&self) -> &TestServiceClient<Self::SvcType> {
|
|
153
218
|
self.client.test_client()
|
|
154
219
|
}
|
|
155
220
|
|
|
156
|
-
fn
|
|
221
|
+
fn test_client_mut(&mut self) -> &mut TestServiceClient<Self::SvcType> {
|
|
222
|
+
self.client.test_client_mut()
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
fn health_client(&self) -> &HealthClient<Self::SvcType> {
|
|
157
226
|
self.client.health_client()
|
|
158
227
|
}
|
|
228
|
+
|
|
229
|
+
fn health_client_mut(&mut self) -> &mut HealthClient<Self::SvcType> {
|
|
230
|
+
self.client.health_client_mut()
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
fn get_workers_info(&self) -> Option<Arc<SlotManager>> {
|
|
234
|
+
Some(self.workers())
|
|
235
|
+
}
|
|
159
236
|
}
|
|
160
237
|
|
|
161
238
|
impl RawClientLike for Client {
|
|
162
239
|
type SvcType = InterceptedMetricsSvc;
|
|
163
240
|
|
|
164
|
-
fn workflow_client(&
|
|
241
|
+
fn workflow_client(&self) -> &WorkflowServiceClient<Self::SvcType> {
|
|
165
242
|
self.inner.workflow_client()
|
|
166
243
|
}
|
|
167
244
|
|
|
168
|
-
fn
|
|
245
|
+
fn workflow_client_mut(&mut self) -> &mut WorkflowServiceClient<Self::SvcType> {
|
|
246
|
+
self.inner.workflow_client_mut()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
fn operator_client(&self) -> &OperatorServiceClient<Self::SvcType> {
|
|
169
250
|
self.inner.operator_client()
|
|
170
251
|
}
|
|
171
252
|
|
|
172
|
-
fn
|
|
253
|
+
fn operator_client_mut(&mut self) -> &mut OperatorServiceClient<Self::SvcType> {
|
|
254
|
+
self.inner.operator_client_mut()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fn test_client(&self) -> &TestServiceClient<Self::SvcType> {
|
|
173
258
|
self.inner.test_client()
|
|
174
259
|
}
|
|
175
260
|
|
|
176
|
-
fn
|
|
261
|
+
fn test_client_mut(&mut self) -> &mut TestServiceClient<Self::SvcType> {
|
|
262
|
+
self.inner.test_client_mut()
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
fn health_client(&self) -> &HealthClient<Self::SvcType> {
|
|
177
266
|
self.inner.health_client()
|
|
178
267
|
}
|
|
268
|
+
|
|
269
|
+
fn health_client_mut(&mut self) -> &mut HealthClient<Self::SvcType> {
|
|
270
|
+
self.inner.health_client_mut()
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
fn get_workers_info(&self) -> Option<Arc<SlotManager>> {
|
|
274
|
+
self.inner.get_workers_info()
|
|
275
|
+
}
|
|
179
276
|
}
|
|
180
277
|
|
|
181
278
|
/// Helper for cloning a tonic request as long as the inner message may be cloned.
|
|
@@ -199,10 +296,10 @@ fn req_cloner<T: Clone>(cloneme: &Request<T>) -> Request<T> {
|
|
|
199
296
|
|
|
200
297
|
#[derive(Debug)]
|
|
201
298
|
pub(super) struct AttachMetricLabels {
|
|
202
|
-
pub(super) labels: Vec<
|
|
299
|
+
pub(super) labels: Vec<MetricKeyValue>,
|
|
203
300
|
}
|
|
204
301
|
impl AttachMetricLabels {
|
|
205
|
-
pub fn new(kvs: impl Into<Vec<
|
|
302
|
+
pub fn new(kvs: impl Into<Vec<MetricKeyValue>>) -> Self {
|
|
206
303
|
Self { labels: kvs.into() }
|
|
207
304
|
}
|
|
208
305
|
pub fn namespace(ns: impl Into<String>) -> Self {
|
|
@@ -280,10 +377,29 @@ macro_rules! proxy {
|
|
|
280
377
|
self.call(stringify!($method), fact, request.into_request())
|
|
281
378
|
}
|
|
282
379
|
};
|
|
380
|
+
($client_type:tt, $client_meth:ident, $method:ident, $req:ty, $resp:ty,
|
|
381
|
+
$closure_before:expr, $closure_after:expr) => {
|
|
382
|
+
#[doc = concat!("See [", stringify!($client_type), "::", stringify!($method), "]")]
|
|
383
|
+
fn $method(
|
|
384
|
+
&mut self,
|
|
385
|
+
request: impl tonic::IntoRequest<$req>,
|
|
386
|
+
) -> BoxFuture<Result<tonic::Response<$resp>, tonic::Status>> {
|
|
387
|
+
#[allow(unused_mut)]
|
|
388
|
+
let fact = |c: &mut Self, mut req: tonic::Request<$req>| {
|
|
389
|
+
let data = type_closure_two_arg(&mut req, c.get_workers_info().unwrap(),
|
|
390
|
+
$closure_before);
|
|
391
|
+
let mut c = c.$client_meth().clone();
|
|
392
|
+
async move {
|
|
393
|
+
type_closure_two_arg(c.$method(req).await, data, $closure_after)
|
|
394
|
+
}.boxed()
|
|
395
|
+
};
|
|
396
|
+
self.call(stringify!($method), fact, request.into_request())
|
|
397
|
+
}
|
|
398
|
+
};
|
|
283
399
|
}
|
|
284
400
|
macro_rules! proxier {
|
|
285
401
|
( $trait_name:ident; $impl_list_name:ident; $client_type:tt; $client_meth:ident;
|
|
286
|
-
$(($method:ident, $req:ty, $resp:ty $(, $closure:expr)?
|
|
402
|
+
$(($method:ident, $req:ty, $resp:ty $(, $closure:expr $(, $closure_after:expr)?)? );)* ) => {
|
|
287
403
|
#[cfg(test)]
|
|
288
404
|
const $impl_list_name: &'static [&'static str] = &[$(stringify!($method)),*];
|
|
289
405
|
/// Trait version of the generated client with modifications to attach appropriate metric
|
|
@@ -301,7 +417,8 @@ macro_rules! proxier {
|
|
|
301
417
|
as tonic::codegen::Body>::Error: Into<tonic::codegen::StdError> + Send,
|
|
302
418
|
{
|
|
303
419
|
$(
|
|
304
|
-
proxy!($client_type, $client_meth, $method, $req, $resp
|
|
420
|
+
proxy!($client_type, $client_meth, $method, $req, $resp
|
|
421
|
+
$(,$closure $(,$closure_after)*)*);
|
|
305
422
|
)*
|
|
306
423
|
}
|
|
307
424
|
};
|
|
@@ -312,8 +429,12 @@ fn type_closure_arg<T, R>(arg: T, f: impl FnOnce(T) -> R) -> R {
|
|
|
312
429
|
f(arg)
|
|
313
430
|
}
|
|
314
431
|
|
|
432
|
+
fn type_closure_two_arg<T, R, S>(arg1: R, arg2: T, f: impl FnOnce(R, T) -> S) -> S {
|
|
433
|
+
f(arg1, arg2)
|
|
434
|
+
}
|
|
435
|
+
|
|
315
436
|
proxier! {
|
|
316
|
-
WorkflowService; ALL_IMPLEMENTED_WORKFLOW_SERVICE_RPCS; WorkflowServiceClient;
|
|
437
|
+
WorkflowService; ALL_IMPLEMENTED_WORKFLOW_SERVICE_RPCS; WorkflowServiceClient; workflow_client_mut;
|
|
317
438
|
(
|
|
318
439
|
register_namespace,
|
|
319
440
|
RegisterNamespaceRequest,
|
|
@@ -359,10 +480,35 @@ proxier! {
|
|
|
359
480
|
start_workflow_execution,
|
|
360
481
|
StartWorkflowExecutionRequest,
|
|
361
482
|
StartWorkflowExecutionResponse,
|
|
362
|
-
|r| {
|
|
483
|
+
|r, workers| {
|
|
484
|
+
let mut slot: Option<Box<dyn Slot + Send>> = None;
|
|
363
485
|
let mut labels = AttachMetricLabels::namespace(r.get_ref().namespace.clone());
|
|
364
486
|
labels.task_q(r.get_ref().task_queue.clone());
|
|
365
487
|
r.extensions_mut().insert(labels);
|
|
488
|
+
let req_mut = r.get_mut();
|
|
489
|
+
if req_mut.request_eager_execution {
|
|
490
|
+
let namespace = req_mut.namespace.clone();
|
|
491
|
+
let task_queue = req_mut.task_queue.clone().unwrap().name.clone();
|
|
492
|
+
match workers.try_reserve_wft_slot(namespace, task_queue) {
|
|
493
|
+
Some(s) => slot = Some(s),
|
|
494
|
+
None => req_mut.request_eager_execution = false
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
slot
|
|
498
|
+
},
|
|
499
|
+
|resp, slot| {
|
|
500
|
+
if let Some(mut s) = slot {
|
|
501
|
+
if let Ok(response) = resp.as_ref() {
|
|
502
|
+
if let Some(task) = response.get_ref().clone().eager_workflow_task {
|
|
503
|
+
if let Err(e) = s.schedule_wft(task) {
|
|
504
|
+
// This is a latency issue, i.e., the client does not need to handle
|
|
505
|
+
// this error, because the WFT will be retried after a timeout.
|
|
506
|
+
warn!(details = ?e, "Eager workflow task rejected by worker.");
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
resp
|
|
366
512
|
}
|
|
367
513
|
);
|
|
368
514
|
(
|
|
@@ -825,7 +971,7 @@ proxier! {
|
|
|
825
971
|
}
|
|
826
972
|
|
|
827
973
|
proxier! {
|
|
828
|
-
OperatorService; ALL_IMPLEMENTED_OPERATOR_SERVICE_RPCS; OperatorServiceClient;
|
|
974
|
+
OperatorService; ALL_IMPLEMENTED_OPERATOR_SERVICE_RPCS; OperatorServiceClient; operator_client_mut;
|
|
829
975
|
(add_search_attributes, AddSearchAttributesRequest, AddSearchAttributesResponse);
|
|
830
976
|
(remove_search_attributes, RemoveSearchAttributesRequest, RemoveSearchAttributesResponse);
|
|
831
977
|
(list_search_attributes, ListSearchAttributesRequest, ListSearchAttributesResponse);
|
|
@@ -841,7 +987,7 @@ proxier! {
|
|
|
841
987
|
}
|
|
842
988
|
|
|
843
989
|
proxier! {
|
|
844
|
-
TestService; ALL_IMPLEMENTED_TEST_SERVICE_RPCS; TestServiceClient;
|
|
990
|
+
TestService; ALL_IMPLEMENTED_TEST_SERVICE_RPCS; TestServiceClient; test_client_mut;
|
|
845
991
|
(lock_time_skipping, LockTimeSkippingRequest, LockTimeSkippingResponse);
|
|
846
992
|
(unlock_time_skipping, UnlockTimeSkippingRequest, UnlockTimeSkippingResponse);
|
|
847
993
|
(sleep, SleepRequest, SleepResponse);
|
|
@@ -851,7 +997,7 @@ proxier! {
|
|
|
851
997
|
}
|
|
852
998
|
|
|
853
999
|
proxier! {
|
|
854
|
-
HealthService; ALL_IMPLEMENTED_HEALTH_SERVICE_RPCS; HealthClient;
|
|
1000
|
+
HealthService; ALL_IMPLEMENTED_HEALTH_SERVICE_RPCS; HealthClient; health_client_mut;
|
|
855
1001
|
(check, HealthCheckRequest, HealthCheckResponse);
|
|
856
1002
|
(watch, HealthCheckRequest, tonic::codec::Streaming<HealthCheckResponse>);
|
|
857
1003
|
}
|
|
@@ -874,7 +1020,7 @@ mod tests {
|
|
|
874
1020
|
|
|
875
1021
|
let list_ns_req = ListNamespacesRequest::default();
|
|
876
1022
|
let fact = |c: &mut RetryClient<_>, req| {
|
|
877
|
-
let mut c = c.
|
|
1023
|
+
let mut c = c.workflow_client_mut().clone();
|
|
878
1024
|
async move { c.list_namespaces(req).await }.boxed()
|
|
879
1025
|
};
|
|
880
1026
|
retry_client
|
|
@@ -885,7 +1031,7 @@ mod tests {
|
|
|
885
1031
|
// Operator svc method
|
|
886
1032
|
let del_ns_req = DeleteNamespaceRequest::default();
|
|
887
1033
|
let fact = |c: &mut RetryClient<_>, req| {
|
|
888
|
-
let mut c = c.
|
|
1034
|
+
let mut c = c.operator_client_mut().clone();
|
|
889
1035
|
async move { c.delete_namespace(req).await }.boxed()
|
|
890
1036
|
};
|
|
891
1037
|
retry_client
|
|
@@ -924,27 +1070,27 @@ mod tests {
|
|
|
924
1070
|
fn verify_all_workflow_service_methods_implemented() {
|
|
925
1071
|
// This is less work than trying to hook into the codegen process
|
|
926
1072
|
let proto_def =
|
|
927
|
-
include_str!("../../protos/api_upstream/temporal/api/workflowservice/v1/service.proto");
|
|
1073
|
+
include_str!("../../sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto");
|
|
928
1074
|
verify_methods(proto_def, ALL_IMPLEMENTED_WORKFLOW_SERVICE_RPCS);
|
|
929
1075
|
}
|
|
930
1076
|
|
|
931
1077
|
#[test]
|
|
932
1078
|
fn verify_all_operator_service_methods_implemented() {
|
|
933
1079
|
let proto_def =
|
|
934
|
-
include_str!("../../protos/api_upstream/temporal/api/operatorservice/v1/service.proto");
|
|
1080
|
+
include_str!("../../sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto");
|
|
935
1081
|
verify_methods(proto_def, ALL_IMPLEMENTED_OPERATOR_SERVICE_RPCS);
|
|
936
1082
|
}
|
|
937
1083
|
|
|
938
1084
|
#[test]
|
|
939
1085
|
fn verify_all_test_service_methods_implemented() {
|
|
940
1086
|
let proto_def =
|
|
941
|
-
include_str!("../../protos/testsrv_upstream/temporal/api/testservice/v1/service.proto");
|
|
1087
|
+
include_str!("../../sdk-core-protos/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto");
|
|
942
1088
|
verify_methods(proto_def, ALL_IMPLEMENTED_TEST_SERVICE_RPCS);
|
|
943
1089
|
}
|
|
944
1090
|
|
|
945
1091
|
#[test]
|
|
946
1092
|
fn verify_all_health_service_methods_implemented() {
|
|
947
|
-
let proto_def = include_str!("../../protos/grpc/health/v1/health.proto");
|
|
1093
|
+
let proto_def = include_str!("../../sdk-core-protos/protos/grpc/health/v1/health.proto");
|
|
948
1094
|
verify_methods(proto_def, ALL_IMPLEMENTED_HEALTH_SERVICE_RPCS);
|
|
949
1095
|
}
|
|
950
1096
|
}
|
|
@@ -11,6 +11,7 @@ use temporal_sdk_core_protos::{
|
|
|
11
11
|
common::v1::{Payload, Payloads},
|
|
12
12
|
failure::v1::Failure,
|
|
13
13
|
query::v1::WorkflowQuery,
|
|
14
|
+
update,
|
|
14
15
|
workflowservice::v1::*,
|
|
15
16
|
},
|
|
16
17
|
TaskToken,
|
|
@@ -526,6 +527,25 @@ where
|
|
|
526
527
|
retry_call!(self, get_search_attributes)
|
|
527
528
|
}
|
|
528
529
|
|
|
530
|
+
async fn update_workflow_execution(
|
|
531
|
+
&self,
|
|
532
|
+
workflow_id: String,
|
|
533
|
+
run_id: String,
|
|
534
|
+
name: String,
|
|
535
|
+
wait_policy: update::v1::WaitPolicy,
|
|
536
|
+
args: Option<Payloads>,
|
|
537
|
+
) -> Result<UpdateWorkflowExecutionResponse> {
|
|
538
|
+
retry_call!(
|
|
539
|
+
self,
|
|
540
|
+
update_workflow_execution,
|
|
541
|
+
workflow_id.clone(),
|
|
542
|
+
run_id.clone(),
|
|
543
|
+
name.clone(),
|
|
544
|
+
wait_policy.clone(),
|
|
545
|
+
args.clone()
|
|
546
|
+
)
|
|
547
|
+
}
|
|
548
|
+
|
|
529
549
|
fn get_options(&self) -> &ClientOptions {
|
|
530
550
|
self.client.get_options()
|
|
531
551
|
}
|