@temporalio/core-bridge 1.13.0 → 1.13.2
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 +239 -382
- package/Cargo.toml +11 -11
- package/lib/native.d.ts +10 -3
- package/package.json +3 -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/.cargo/config.toml +71 -11
- package/sdk-core/.clippy.toml +1 -0
- package/sdk-core/.github/workflows/heavy.yml +2 -0
- package/sdk-core/.github/workflows/per-pr.yml +50 -18
- package/sdk-core/ARCHITECTURE.md +44 -48
- package/sdk-core/Cargo.toml +26 -7
- package/sdk-core/README.md +4 -0
- package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
- package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
- package/sdk-core/arch_docs/sdks_intro.md +299 -0
- package/sdk-core/client/Cargo.toml +8 -7
- package/sdk-core/client/src/callback_based.rs +1 -2
- package/sdk-core/client/src/lib.rs +485 -299
- package/sdk-core/client/src/metrics.rs +32 -8
- package/sdk-core/client/src/proxy.rs +124 -5
- package/sdk-core/client/src/raw.rs +598 -307
- package/sdk-core/client/src/replaceable.rs +253 -0
- package/sdk-core/client/src/retry.rs +9 -6
- package/sdk-core/client/src/worker_registry/mod.rs +19 -3
- package/sdk-core/client/src/workflow_handle/mod.rs +20 -17
- package/sdk-core/core/Cargo.toml +100 -31
- package/sdk-core/core/src/core_tests/activity_tasks.rs +55 -225
- package/sdk-core/core/src/core_tests/mod.rs +2 -8
- package/sdk-core/core/src/core_tests/queries.rs +3 -5
- package/sdk-core/core/src/core_tests/replay_flag.rs +3 -62
- package/sdk-core/core/src/core_tests/updates.rs +4 -5
- package/sdk-core/core/src/core_tests/workers.rs +4 -3
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +10 -7
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +28 -291
- package/sdk-core/core/src/ephemeral_server/mod.rs +15 -3
- package/sdk-core/core/src/internal_flags.rs +11 -1
- package/sdk-core/core/src/lib.rs +50 -36
- package/sdk-core/core/src/pollers/mod.rs +5 -5
- package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
- package/sdk-core/core/src/protosext/mod.rs +13 -5
- package/sdk-core/core/src/protosext/protocol_messages.rs +4 -11
- package/sdk-core/core/src/retry_logic.rs +256 -108
- package/sdk-core/core/src/telemetry/metrics.rs +1 -0
- package/sdk-core/core/src/telemetry/mod.rs +8 -2
- package/sdk-core/core/src/telemetry/prometheus_meter.rs +2 -2
- package/sdk-core/core/src/test_help/integ_helpers.rs +971 -0
- package/sdk-core/core/src/test_help/mod.rs +10 -1100
- package/sdk-core/core/src/test_help/unit_helpers.rs +218 -0
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +42 -6
- package/sdk-core/core/src/worker/activities/local_activities.rs +19 -19
- package/sdk-core/core/src/worker/activities.rs +10 -3
- package/sdk-core/core/src/worker/client/mocks.rs +3 -3
- package/sdk-core/core/src/worker/client.rs +130 -93
- package/sdk-core/core/src/worker/heartbeat.rs +12 -13
- package/sdk-core/core/src/worker/mod.rs +31 -21
- package/sdk-core/core/src/worker/nexus.rs +14 -3
- package/sdk-core/core/src/worker/slot_provider.rs +9 -0
- package/sdk-core/core/src/worker/tuner.rs +159 -0
- package/sdk-core/core/src/worker/workflow/history_update.rs +3 -265
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -54
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -82
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -67
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -192
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -43
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +6 -554
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -71
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +102 -3
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +10 -539
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -139
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -119
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -63
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +9 -4
- package/sdk-core/core/src/worker/workflow/mod.rs +5 -1
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +8 -3
- package/sdk-core/core-api/Cargo.toml +4 -4
- package/sdk-core/core-api/src/envconfig.rs +153 -54
- package/sdk-core/core-api/src/lib.rs +68 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +2 -1
- package/sdk-core/core-api/src/telemetry.rs +13 -0
- package/sdk-core/core-c-bridge/Cargo.toml +13 -8
- package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +184 -22
- package/sdk-core/core-c-bridge/src/client.rs +462 -184
- package/sdk-core/core-c-bridge/src/envconfig.rs +314 -0
- package/sdk-core/core-c-bridge/src/lib.rs +1 -0
- package/sdk-core/core-c-bridge/src/random.rs +4 -4
- package/sdk-core/core-c-bridge/src/runtime.rs +22 -23
- package/sdk-core/core-c-bridge/src/testing.rs +1 -4
- package/sdk-core/core-c-bridge/src/tests/context.rs +31 -31
- package/sdk-core/core-c-bridge/src/tests/mod.rs +32 -28
- package/sdk-core/core-c-bridge/src/tests/utils.rs +7 -7
- package/sdk-core/core-c-bridge/src/worker.rs +319 -66
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -1
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +5 -5
- package/sdk-core/sdk/Cargo.toml +8 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/app_data.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -4
- package/sdk-core/sdk/src/lib.rs +1 -5
- package/sdk-core/sdk/src/workflow_context/options.rs +10 -1
- package/sdk-core/sdk/src/workflow_future.rs +1 -1
- package/sdk-core/sdk-core-protos/Cargo.toml +6 -6
- package/sdk-core/sdk-core-protos/build.rs +10 -23
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +9 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +254 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +234 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- package/sdk-core/{test-utils → sdk-core-protos}/src/canned_histories.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -2
- package/sdk-core/sdk-core-protos/src/lib.rs +25 -9
- package/sdk-core/sdk-core-protos/src/test_utils.rs +89 -0
- package/sdk-core/sdk-core-protos/src/utilities.rs +14 -5
- package/sdk-core/tests/c_bridge_smoke_test.c +10 -0
- package/sdk-core/tests/cloud_tests.rs +10 -8
- package/sdk-core/tests/common/http_proxy.rs +134 -0
- package/sdk-core/{test-utils/src/lib.rs → tests/common/mod.rs} +214 -281
- package/sdk-core/{test-utils/src → tests/common}/workflows.rs +4 -3
- package/sdk-core/tests/fuzzy_workflow.rs +1 -1
- package/sdk-core/tests/global_metric_tests.rs +8 -7
- package/sdk-core/tests/heavy_tests.rs +7 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +111 -24
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +14 -9
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/metrics_tests.rs +114 -14
- package/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
- package/sdk-core/tests/integ_tests/polling_tests.rs +311 -93
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/update_tests.rs +13 -7
- package/sdk-core/tests/integ_tests/visibility_tests.rs +26 -9
- package/sdk-core/tests/integ_tests/worker_tests.rs +668 -13
- package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +40 -24
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +244 -11
- package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +78 -2
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +61 -2
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +465 -7
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +41 -2
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +315 -3
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1990 -14
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +65 -2
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +123 -23
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +525 -3
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +65 -16
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +32 -23
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +126 -5
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +1 -2
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +124 -8
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +62 -2
- package/sdk-core/tests/integ_tests/workflow_tests.rs +67 -8
- package/sdk-core/tests/main.rs +26 -17
- package/sdk-core/tests/manual_tests.rs +5 -1
- package/sdk-core/tests/runner.rs +22 -40
- package/sdk-core/tests/shared_tests/mod.rs +1 -1
- package/sdk-core/tests/shared_tests/priority.rs +1 -1
- package/sdk-core/{core/benches/workflow_replay.rs → tests/workflow_replay_bench.rs} +10 -5
- package/src/client.rs +97 -20
- package/src/helpers/callbacks.rs +4 -4
- package/src/helpers/errors.rs +7 -1
- package/src/helpers/handles.rs +1 -0
- package/src/helpers/try_from_js.rs +4 -3
- package/src/lib.rs +3 -2
- package/src/metrics.rs +3 -0
- package/src/runtime.rs +5 -2
- package/src/worker.rs +9 -12
- package/ts/native.ts +13 -3
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
- package/sdk-core/core/src/core_tests/determinism.rs +0 -318
- package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
- package/sdk-core/test-utils/Cargo.toml +0 -38
- package/sdk-core/test-utils/src/histfetch.rs +0 -28
- package/sdk-core/test-utils/src/interceptors.rs +0 -46
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
use crate::{AttachMetricLabels, CallType, callback_based, dbg_panic};
|
|
2
|
-
use futures_util::
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
use futures_util::{
|
|
3
|
+
FutureExt, TryFutureExt,
|
|
4
|
+
future::{BoxFuture, Either},
|
|
5
|
+
};
|
|
5
6
|
use std::{
|
|
6
7
|
fmt,
|
|
7
8
|
sync::Arc,
|
|
8
9
|
task::{Context, Poll},
|
|
9
10
|
time::{Duration, Instant},
|
|
10
11
|
};
|
|
11
|
-
use temporal_sdk_core_api::telemetry::
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
use temporal_sdk_core_api::telemetry::{
|
|
13
|
+
TaskQueueLabelStrategy,
|
|
14
|
+
metrics::{
|
|
15
|
+
CoreMeter, Counter, CounterBase, HistogramDuration, HistogramDurationBase,
|
|
16
|
+
MetricAttributable, MetricAttributes, MetricKeyValue, MetricParameters, TemporalMeter,
|
|
17
|
+
},
|
|
14
18
|
};
|
|
15
19
|
use tonic::{Code, body::Body, transport::Channel};
|
|
16
20
|
use tower::Service;
|
|
@@ -30,6 +34,7 @@ pub(crate) struct MetricsContext {
|
|
|
30
34
|
kvs: MetricAttributes,
|
|
31
35
|
poll_is_long: bool,
|
|
32
36
|
instruments: Instruments,
|
|
37
|
+
task_queue_label_strategy: TaskQueueLabelStrategy,
|
|
33
38
|
}
|
|
34
39
|
#[derive(Clone)]
|
|
35
40
|
struct Instruments {
|
|
@@ -45,6 +50,7 @@ struct Instruments {
|
|
|
45
50
|
impl MetricsContext {
|
|
46
51
|
pub(crate) fn new(tm: TemporalMeter) -> Self {
|
|
47
52
|
let meter = tm.inner;
|
|
53
|
+
let task_queue_label_strategy = tm.task_queue_label_strategy;
|
|
48
54
|
let kvs = meter.new_attributes(tm.default_attribs);
|
|
49
55
|
let instruments = Instruments {
|
|
50
56
|
svc_request: meter.counter(MetricParameters {
|
|
@@ -83,6 +89,7 @@ impl MetricsContext {
|
|
|
83
89
|
poll_is_long: false,
|
|
84
90
|
instruments,
|
|
85
91
|
meter,
|
|
92
|
+
task_queue_label_strategy,
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
95
|
|
|
@@ -207,7 +214,7 @@ fn code_as_screaming_snake(code: &Code) -> &'static str {
|
|
|
207
214
|
|
|
208
215
|
/// Implements metrics functionality for gRPC (really, any http) calls
|
|
209
216
|
#[derive(Debug, Clone)]
|
|
210
|
-
pub struct GrpcMetricSvc {
|
|
217
|
+
pub(crate) struct GrpcMetricSvc {
|
|
211
218
|
pub(crate) inner: ChannelOrGrpcOverride,
|
|
212
219
|
// If set to none, metrics are a no-op
|
|
213
220
|
pub(crate) metrics: Option<MetricsContext>,
|
|
@@ -229,6 +236,7 @@ impl fmt::Debug for ChannelOrGrpcOverride {
|
|
|
229
236
|
}
|
|
230
237
|
}
|
|
231
238
|
|
|
239
|
+
// TODO: Rewrite as a RawGrpcCaller implementation
|
|
232
240
|
impl Service<http::Request<Body>> for GrpcMetricSvc {
|
|
233
241
|
type Response = http::Response<Body>;
|
|
234
242
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
|
@@ -248,7 +256,23 @@ impl Service<http::Request<Body>> for GrpcMetricSvc {
|
|
|
248
256
|
.map(|mut m| {
|
|
249
257
|
// Attach labels from client wrapper
|
|
250
258
|
if let Some(other_labels) = req.extensions_mut().remove::<AttachMetricLabels>() {
|
|
251
|
-
m.with_new_attrs(other_labels.labels)
|
|
259
|
+
m.with_new_attrs(other_labels.labels);
|
|
260
|
+
|
|
261
|
+
if other_labels.normal_task_queue.is_some()
|
|
262
|
+
|| other_labels.sticky_task_queue.is_some()
|
|
263
|
+
{
|
|
264
|
+
let task_queue_name = match m.task_queue_label_strategy {
|
|
265
|
+
TaskQueueLabelStrategy::UseNormal => other_labels.normal_task_queue,
|
|
266
|
+
TaskQueueLabelStrategy::UseNormalAndSticky => other_labels
|
|
267
|
+
.sticky_task_queue
|
|
268
|
+
.or(other_labels.normal_task_queue),
|
|
269
|
+
_ => other_labels.normal_task_queue,
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
if let Some(tq_name) = task_queue_name {
|
|
273
|
+
m.with_new_attrs([task_queue_kv(tq_name)]);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
252
276
|
}
|
|
253
277
|
if let Some(ct) = req.extensions().get::<CallType>()
|
|
254
278
|
&& ct.is_long()
|
|
@@ -2,22 +2,33 @@ use base64::prelude::*;
|
|
|
2
2
|
use http_body_util::Empty;
|
|
3
3
|
use hyper::{body::Bytes, header};
|
|
4
4
|
use hyper_util::{
|
|
5
|
-
client::legacy::
|
|
5
|
+
client::legacy::{
|
|
6
|
+
Client,
|
|
7
|
+
connect::{Connected, Connection},
|
|
8
|
+
},
|
|
6
9
|
rt::{TokioExecutor, TokioIo},
|
|
7
10
|
};
|
|
8
11
|
use std::{
|
|
9
12
|
future::Future,
|
|
13
|
+
io,
|
|
10
14
|
pin::Pin,
|
|
11
15
|
task::{Context, Poll},
|
|
12
16
|
};
|
|
13
|
-
use tokio::
|
|
17
|
+
use tokio::{
|
|
18
|
+
io::{AsyncRead, AsyncWrite, ReadBuf},
|
|
19
|
+
net::TcpStream,
|
|
20
|
+
};
|
|
14
21
|
use tonic::transport::{Channel, Endpoint};
|
|
15
22
|
use tower::{Service, service_fn};
|
|
16
23
|
|
|
24
|
+
#[cfg(unix)]
|
|
25
|
+
use tokio::net::UnixStream;
|
|
26
|
+
|
|
17
27
|
/// Options for HTTP CONNECT proxy.
|
|
18
28
|
#[derive(Clone, Debug)]
|
|
19
29
|
pub struct HttpConnectProxyOptions {
|
|
20
|
-
/// The host:port to proxy through.
|
|
30
|
+
/// The host:port to proxy through for TCP, or unix:/path/to/unix.sock for
|
|
31
|
+
/// Unix socket (which means it must start with "unix:/").
|
|
21
32
|
pub target_addr: String,
|
|
22
33
|
/// Optional HTTP basic auth for the proxy as user/pass tuple.
|
|
23
34
|
pub basic_auth: Option<(String, String)>,
|
|
@@ -72,7 +83,7 @@ impl HttpConnectProxyOptions {
|
|
|
72
83
|
struct OverrideAddrConnector(String);
|
|
73
84
|
|
|
74
85
|
impl Service<hyper::Uri> for OverrideAddrConnector {
|
|
75
|
-
type Response = TokioIo<
|
|
86
|
+
type Response = TokioIo<ProxyStream>;
|
|
76
87
|
|
|
77
88
|
type Error = anyhow::Error;
|
|
78
89
|
|
|
@@ -84,7 +95,115 @@ impl Service<hyper::Uri> for OverrideAddrConnector {
|
|
|
84
95
|
|
|
85
96
|
fn call(&mut self, _uri: hyper::Uri) -> Self::Future {
|
|
86
97
|
let target_addr = self.0.clone();
|
|
87
|
-
let fut = async move {
|
|
98
|
+
let fut = async move {
|
|
99
|
+
Ok(TokioIo::new(
|
|
100
|
+
ProxyStream::connect(target_addr.as_str()).await?,
|
|
101
|
+
))
|
|
102
|
+
};
|
|
88
103
|
Box::pin(fut)
|
|
89
104
|
}
|
|
90
105
|
}
|
|
106
|
+
|
|
107
|
+
/// Visible only for tests
|
|
108
|
+
#[doc(hidden)]
|
|
109
|
+
pub enum ProxyStream {
|
|
110
|
+
Tcp(TcpStream),
|
|
111
|
+
#[cfg(unix)]
|
|
112
|
+
Unix(UnixStream),
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
impl ProxyStream {
|
|
116
|
+
async fn connect(target_addr: &str) -> anyhow::Result<Self> {
|
|
117
|
+
if target_addr.starts_with("unix:/") {
|
|
118
|
+
#[cfg(unix)]
|
|
119
|
+
{
|
|
120
|
+
Ok(ProxyStream::Unix(
|
|
121
|
+
UnixStream::connect(&target_addr[5..]).await?,
|
|
122
|
+
))
|
|
123
|
+
}
|
|
124
|
+
#[cfg(not(unix))]
|
|
125
|
+
{
|
|
126
|
+
Err(anyhow::anyhow!(
|
|
127
|
+
"Unix sockets are not supported on this platform"
|
|
128
|
+
))
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
Ok(ProxyStream::Tcp(TcpStream::connect(target_addr).await?))
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
impl AsyncRead for ProxyStream {
|
|
137
|
+
fn poll_read(
|
|
138
|
+
self: Pin<&mut Self>,
|
|
139
|
+
cx: &mut Context<'_>,
|
|
140
|
+
buf: &mut ReadBuf<'_>,
|
|
141
|
+
) -> Poll<io::Result<()>> {
|
|
142
|
+
match self.get_mut() {
|
|
143
|
+
ProxyStream::Tcp(s) => Pin::new(s).poll_read(cx, buf),
|
|
144
|
+
#[cfg(unix)]
|
|
145
|
+
ProxyStream::Unix(s) => Pin::new(s).poll_read(cx, buf),
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
impl AsyncWrite for ProxyStream {
|
|
151
|
+
fn poll_write(
|
|
152
|
+
self: Pin<&mut Self>,
|
|
153
|
+
cx: &mut Context<'_>,
|
|
154
|
+
buf: &[u8],
|
|
155
|
+
) -> Poll<io::Result<usize>> {
|
|
156
|
+
match self.get_mut() {
|
|
157
|
+
ProxyStream::Tcp(s) => Pin::new(s).poll_write(cx, buf),
|
|
158
|
+
#[cfg(unix)]
|
|
159
|
+
ProxyStream::Unix(s) => Pin::new(s).poll_write(cx, buf),
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fn poll_write_vectored(
|
|
164
|
+
self: Pin<&mut Self>,
|
|
165
|
+
cx: &mut Context<'_>,
|
|
166
|
+
bufs: &[io::IoSlice<'_>],
|
|
167
|
+
) -> Poll<io::Result<usize>> {
|
|
168
|
+
match self.get_mut() {
|
|
169
|
+
ProxyStream::Tcp(s) => Pin::new(s).poll_write_vectored(cx, bufs),
|
|
170
|
+
#[cfg(unix)]
|
|
171
|
+
ProxyStream::Unix(s) => Pin::new(s).poll_write_vectored(cx, bufs),
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fn is_write_vectored(&self) -> bool {
|
|
176
|
+
match self {
|
|
177
|
+
ProxyStream::Tcp(s) => s.is_write_vectored(),
|
|
178
|
+
#[cfg(unix)]
|
|
179
|
+
ProxyStream::Unix(s) => s.is_write_vectored(),
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
|
184
|
+
match self.get_mut() {
|
|
185
|
+
ProxyStream::Tcp(s) => Pin::new(s).poll_flush(cx),
|
|
186
|
+
#[cfg(unix)]
|
|
187
|
+
ProxyStream::Unix(s) => Pin::new(s).poll_flush(cx),
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
|
192
|
+
match self.get_mut() {
|
|
193
|
+
ProxyStream::Tcp(s) => Pin::new(s).poll_shutdown(cx),
|
|
194
|
+
#[cfg(unix)]
|
|
195
|
+
ProxyStream::Unix(s) => Pin::new(s).poll_shutdown(cx),
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
impl Connection for ProxyStream {
|
|
201
|
+
fn connected(&self) -> Connected {
|
|
202
|
+
match self {
|
|
203
|
+
ProxyStream::Tcp(s) => s.connected(),
|
|
204
|
+
// There is no special connected metadata for Unix sockets
|
|
205
|
+
#[cfg(unix)]
|
|
206
|
+
ProxyStream::Unix(_) => Connected::new(),
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|