Skip to main content

Mux

Struct Mux 

Source
pub struct Mux<Front: SocketHandler, L: ListenerHandler + L7ListenerHandler> {
    pub configured_frontend_timeout: Duration,
    pub frontend_token: Token,
    pub frontend: Connection<Front>,
    pub router: Router,
    pub context: Context<L>,
    pub timeouts: MuxTimeouts,
    pub session_ulid: Ulid,
    /* private fields */
}

Fields§

§configured_frontend_timeout: Duration§frontend_token: Token§frontend: Connection<Front>§router: Router§context: Context<L>§timeouts: MuxTimeouts

The adapter’s wheel handles, one per live token (the frontend plus every backend in router.backends).

The H1/H2 cores no longer own a TimeoutContainer: they publish the instant they want to be called back at through Connection::poll_timeout and Mux::reschedule reflects that onto crate::timer, arming only when what the wheel holds differs from what the core wants. This map is the ONLY thing in the mux that talks to the timer wheel.

A handle for a token that has left router.backends is dropped by reschedule’s retain, and TimeoutContainer::drop cancels its entry — which is why no backend-removal site has to remember to cancel.

§session_ulid: Ulid

Per-session correlation ID generated at construction time. Included in every log line emitted from this module so all events for a single frontend connection can be reassembled (independent of the ephemeral per-stream request id used by access logs).

Implementations§

Source§

impl<Front: SocketHandler, L: ListenerHandler + L7ListenerHandler> Mux<Front, L>

Source

pub fn front_socket(&self) -> &TcpStream ⓘ

Source

pub fn take_loop_budget_yield(&mut self) -> bool

Take the flag the last ready pass set when it yielded at MAX_LOOP_ITERATIONS with work left (Context::loop_budget_yielded). The session answers ProxySession::yielded with it.

Source

pub fn has_pending_backend_failure(&self) -> bool

Whether a backend connection carries a HUP or ERROR event that no socket readiness will deliver again: the flag Mux::timeout_inner sets on a dial whose connect timed out. The session answers ProxySession::needs_ready_pass with this, so Server::timeout runs the ready pass that counts the failure and fails the request over (sozu-proxy/sozu#1800).

Source

pub fn frontend_peer_closed(&self) -> bool

Whether the client has closed its side of the frontend connection, the peer_closed argument the session’s close path hands to shutdown_write. See Connection::peer_closed.

Trait Implementations§

Source§

impl<Front: SocketHandler + Debug, L: ListenerHandler + L7ListenerHandler> SessionState for Mux<Front, L>

Source§

fn ready( &mut self, session: Rc<RefCell<dyn ProxySession>>, proxy: Rc<RefCell<dyn L7Proxy>>, metrics: &mut SessionMetrics, ) -> SessionResult

Thin wrapper over Mux::ready_inner whose only job is to run Mux::reschedule on the way out. ready_inner has a dozen return sites; arming the wheel at each of them by hand is precisely the discipline this refactor exists to remove.

Source§

fn timeout(&mut self, token: Token, metrics: &mut SessionMetrics) -> StateResult

Thin wrapper over Mux::timeout_inner: reschedule on the way out, then check the two properties carried over from UdpManager.

Source§

fn shutting_down(&mut self) -> bool

Thin wrapper over Mux::shutting_down_inner: it drives frontend I/O and can change a core deadline, so it owes the wheel a reschedule on every exit.

Source§

fn targets(&self, target: &SessionTarget) -> bool

A mux session is targeted when one of its backend connections, connecting or connected, is: an H2 frontend multiplexing several clusters is targeted by each of them.

Source§

fn update_readiness(&mut self, token: Token, events: Ready)

if the event loop got an event for a token associated with the session, it will call this method
Source§

fn cancel_timeouts(&mut self)

cancel frontend timeout (and backend timeout if present)
Source§

fn print_state(&self, _context: &str)

display the session’s internal state (for debugging purpose), Read more
Source§

fn close( &mut self, proxy: Rc<RefCell<dyn L7Proxy>>, _metrics: &mut SessionMetrics, )

close the state

Auto Trait Implementations§

§

impl<Front, L> !Freeze for Mux<Front, L>

§

impl<Front, L> !RefUnwindSafe for Mux<Front, L>

§

impl<Front, L> !Send for Mux<Front, L>

§

impl<Front, L> !Sync for Mux<Front, L>

§

impl<Front, L> !UnwindSafe for Mux<Front, L>

§

impl<Front, L> Unpin for Mux<Front, L>
where Connection<Front>: Unpin, Context<L>: Unpin,

§

impl<Front, L> UnsafeUnpin for Mux<Front, L>

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<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> Same for T

Source§

type Output = T

Should always be Self
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.