pub struct UdsRelay { /* private fields */ }Expand description
Console’s UDS client for one target.
Why: the dial half of ADR-0034’s relay. Since #5182 it can also START the
target: with a supervisor attached it calls ensure_running before writing
the frame, which is what lets the target stay non-resident. Without one it
dials whatever is already at the path, which is what the tests and any
externally-managed deployment want.
What: a socket path, a timeout, and an optional supervisor. Cheap to clone;
opens a fresh connection per delivery, matching every other UDS client in
this workspace.
Test: relay_* cases in webhook/tests.rs.
Implementations§
Source§impl UdsRelay
impl UdsRelay
Sourcepub fn new(socket: impl Into<PathBuf>) -> Self
pub fn new(socket: impl Into<PathBuf>) -> Self
Target socket with DEFAULT_RELAY_TIMEOUT and no supervision.
Sourcepub fn with_supervisor(
self,
source: impl Into<String>,
supervisor: SharedSupervisor,
) -> Self
pub fn with_supervisor( self, source: impl Into<String>, supervisor: SharedSupervisor, ) -> Self
Start the target on demand, under supervisor, keyed by source.
Test: relay_with_a_supervisor_still_acks_against_a_live_target,
spawn_adopts_a_socket_that_is_already_served.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Override the round-trip budget.
Sourcepub fn timeout(&self) -> Duration
pub fn timeout(&self) -> Duration
Round-trip budget, which is also the sweep’s hands-off grace period for an entry the request path may still be relaying.
Sourcepub async fn deliver(&self, entry: &SpoolEntry) -> RelayOutcome
pub async fn deliver(&self, entry: &SpoolEntry) -> RelayOutcome
Send one delivery and classify the answer.
Why: the classification is the whole safety property. Anything other
than an explicit "ack": true leaves the entry pending, so a target that
accepts a connection and then crashes, or answers with an empty object,
does not cause the delivery to be dropped.
What: dials through the hardened UDS entry point, writes one frame,
reads one frame, and defers the ack decision to
RelayResponse::is_ack so both halves of the contract agree on it. A
JSON-RPC error or a non-ack result is RelayOutcome::Refused; any
transport failure is RelayOutcome::Unreachable.
Never returns Err: every failure is a first-class outcome the caller
must record durably, and an error return invites the let _ = ADR-0034
§2 forbids.
Test: relay_acked_response_is_the_only_ack,
relay_treats_a_result_without_ack_as_refused,
relay_treats_a_jsonrpc_error_as_refused,
relay_reports_unreachable_when_no_listener_is_bound,
relay_reports_unreachable_when_the_target_hangs_up_without_answering.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UdsRelay
impl !UnwindSafe for UdsRelay
impl Freeze for UdsRelay
impl Send for UdsRelay
impl Sync for UdsRelay
impl Unpin for UdsRelay
impl UnsafeUnpin for UdsRelay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more