Skip to main content

ControlAttachment

Struct ControlAttachment 

Source
pub(crate) struct ControlAttachment {
    plane: Arc<ControlPlane>,
    commands: Sender<SessionCommand>,
    inbox: Mutex<Option<Receiver<SessionCommand>>>,
}
Expand description

A session’s attachment to its proxy’s control plane.

Built when the proxy constructs the session, which is before the session runs and long before it has anything worth reaching. It holds the channel’s two halves apart until then: the sending half goes into the registry when the session registers, and the receiving half is taken out once, by the session itself, when it has the context to serve it.

A session built directly, rather than by a proxy’s accept loop, has no attachment at all — it belongs to no proxy, so there is no plane for it to register with.

Fields§

§plane: Arc<ControlPlane>§commands: Sender<SessionCommand>§inbox: Mutex<Option<Receiver<SessionCommand>>>

Implementations§

Source§

impl ControlAttachment

Source

pub(crate) fn new(plane: Arc<ControlPlane>) -> Self

Attach a session to plane, minting its command channel.

Source

pub(crate) fn register( &self, id: SessionId, cancel: CancellationToken, closer: SessionCloser, streams: Arc<StreamRegistry>, control: [Sender<StreamCommand>; 2], egress: EgressConfig, ) -> SessionGuard

Register this session as live under id, reachable through everything a request might have to touch.

The returned guard is the registration; drop it and the id is gone.

Every argument is state the session builds before it dials the upstream relay, which is why this can be called at the top of the run function: a session spends its longest single operation connecting, and one that only became reachable afterwards would be unreachable for exactly as long as that took.

Source

pub(crate) fn plane(&self) -> Arc<ControlPlane>

The plane this session is attached to.

Handed out so that the session can build a shaper that watches the proxy’s profile. Nothing else the session does needs the plane: the registration goes through Self::register and the command channel through Self::take_inbox, both of which hand back exactly what they cover.

Source

pub(crate) fn take_inbox(&self) -> Option<Receiver<SessionCommand>>

Take the receiving half of the command channel.

Answers Some exactly once per session. A second caller gets None rather than a second receiver, because two tasks draining one inbox would each see half the requests and neither would know it.

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.

§

impl<T> Instrument for T

§

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

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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