pub struct Conduit { /* private fields */ }Implementations§
Source§impl Conduit
impl Conduit
pub fn new() -> Arc<Self> ⓘ
Sourcepub async fn host(&self) -> Option<Host>
pub async fn host(&self) -> Option<Host>
Wait for a relay to be attached, returning it as soon as one is.
A plugin can — and on a cold start will — connect before the host has dialed in. Holding here rather than buffering is deliberate: the client’s bytes stay in the kernel receive buffer, so backpressure is the TCP window and this process never grows a queue of its own.
None only once the Conduit itself is gone, which means the
process is shutting down and there is nothing left to wait for.
Sourcepub async fn detached(&self, epoch: u64)
pub async fn detached(&self, epoch: u64)
Resolve once epoch is no longer the attached relay — because it
detached, or because a newer one superseded it.
This is what a client connection watches, and it is load-bearing
rather than belt-and-braces. detach sweeps the
streams it knows about, but a client that read the relay just
before it detached can register just after, leaving a stream no
sweep will ever see. Such a client is typically mid-round-trip —
blocked on a response that is never coming — and on a loopback
socket with no keepalive it would block forever. Watching the
cell makes the value authoritative instead of the sweep, so the
race resolves itself no matter which order the two happen in.
Sourcepub fn attach(&self, tx: UnboundedSender<Message>) -> u64
pub fn attach(&self, tx: UnboundedSender<Message>) -> u64
Attach a relay, returning its epoch. Newest wins: a host that redials after a blip supersedes whatever was here.
send_replace, NOT send, and that is the whole correctness of
this function. send reports “no receivers” as an error AND
DISCARDS THE VALUE — and no receiver exists at the moment that
matters most, because Conduit::new keeps only the sender and
every reader subscribes on demand. The normal cold start is
exactly that case: the host dials in and attaches before any
Postgres client has arrived to subscribe, so with send the
relay was stored nowhere, host then saw None
forever, and every client parked until its pool timed out. A
relay that has attached must be visible to clients that arrive
afterwards, so the write cannot be conditional on someone
already watching.
Sourcepub fn open(&self, epoch: u64, tx: UnboundedSender<Bytes>) -> u32
pub fn open(&self, epoch: u64, tx: UnboundedSender<Bytes>) -> u32
Register a client connection and mint its id.
Ids are monotonic and never reused within a container’s life: four billion connections is not a number a plugin container reaches, so there is no wraparound to reason about.
pub fn close(&self, id: u32)
Auto Trait Implementations§
impl !Freeze for Conduit
impl !RefUnwindSafe for Conduit
impl Send for Conduit
impl Sync for Conduit
impl Unpin for Conduit
impl UnsafeUnpin for Conduit
impl UnwindSafe for Conduit
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
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