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: CancellationTokenThe 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: SessionCloserWhere 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: EgressConfigThe 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
impl SessionHandle
Sourcefn control_inbox(&self, leg: Leg) -> &Sender<StreamCommand>
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.
Sourcefn request(
&self,
id: SessionId,
command: SessionCommand,
) -> Result<(), ControlError>
fn request( &self, id: SessionId, command: SessionCommand, ) -> Result<(), ControlError>
Hand command to this session’s command task.
Trait Implementations§
Source§impl Clone for SessionHandle
impl Clone for SessionHandle
Source§fn clone(&self) -> SessionHandle
fn clone(&self) -> SessionHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more