Skip to main content

SessionHandle

Struct SessionHandle 

Source
pub(crate) struct SessionHandle {
    cancel: CancellationToken,
    closer: SessionCloser,
    streams: Arc<StreamRegistry>,
    control: [Sender<StreamCommand>; 2],
    egress: EgressConfig,
    commands: Sender<SessionCommand>,
}
Expand description

What the control plane keeps for one live session.

Everything here is either a handle onto shared state the session set up before it began forwarding, or a way to reach a task it spawned. Nothing here is a Transport: the two connections are owned by the forwarding scope, and putting them in a table scanned by every list call would keep them alive past the session that owns them.

The entry can therefore be built at the top of the session’s run function, before the upstream relay has even been dialled — which is what makes a session reachable during the one operation that can take seconds.

Clone because a request takes a copy out from under the registry lock before it does anything with it; holding that lock while talking to a session would let one unresponsive session block every other request.

Fields§

§cancel: CancellationToken

The session’s own token — a child of the proxy’s, so cancelling it ends this session and leaves the proxy accepting. Read, not cancelled, by this module: a session that is already going down is refused rather than asked to do more.

§closer: SessionCloser

Where the close code and reason are fixed, and where the session’s own teardown reads them back out.

§streams: Arc<StreamRegistry>

Every stream this session is forwarding, and each one’s inbox.

§control: [Sender<StreamCommand>; 2]

The two control-stream directions’ inboxes, indexed by the leg whose peer decodes what is written there. See Self::control_inbox.

§egress: EgressConfig

The session’s egress knobs, for the drain window a close is given.

§commands: Sender<SessionCommand>

Where a request for the session as a whole is delivered.

Implementations§

Source§

impl SessionHandle

Source

fn control_inbox(&self, leg: Leg) -> &Sender<StreamCommand>

The control-stream inbox whose writes leg’s peer decodes.

The mapping is a half-turn and is worth stating once: the pipe that forwards from the client writes to the relay, so a message meant for the relay’s decoder — Leg::Upstream — goes to the client-to-proxy direction’s inbox, and a message for the client goes to the relay-to-proxy direction’s.

Source

fn request( &self, id: SessionId, command: SessionCommand, ) -> Result<(), ControlError>

Hand command to this session’s command task.

Trait Implementations§

Source§

impl Clone for SessionHandle

Source§

fn clone(&self) -> SessionHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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