Skip to main content

Conduit

Struct Conduit 

Source
pub struct Conduit { /* private fields */ }

Implementations§

Source§

impl Conduit

Source

pub fn new() -> Arc<Self> ⓘ

Source

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.

Source

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.

Source

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.

Source

pub fn detach(&self, epoch: u64)

A relay ended.

Source

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.

Source

pub fn close(&self, id: u32)

Source

pub fn route(&self, frame: Frame)

Route one frame that arrived from the host. Never awaits.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more