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
impl ControlAttachment
Sourcepub(crate) fn new(plane: Arc<ControlPlane>) -> Self
pub(crate) fn new(plane: Arc<ControlPlane>) -> Self
Attach a session to plane, minting its command channel.
Sourcepub(crate) fn register(
&self,
id: SessionId,
cancel: CancellationToken,
closer: SessionCloser,
streams: Arc<StreamRegistry>,
control: [Sender<StreamCommand>; 2],
egress: EgressConfig,
) -> SessionGuard
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.
Sourcepub(crate) fn plane(&self) -> Arc<ControlPlane> ⓘ
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.
Sourcepub(crate) fn take_inbox(&self) -> Option<Receiver<SessionCommand>>
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.