Skip to main content

ProxySession

Trait ProxySession 

Source
pub trait ProxySession {
Show 14 methods // Required methods fn protocol(&self) -> Protocol; fn ready(&mut self, session: Rc<RefCell<dyn ProxySession>>) -> bool; fn update_readiness(&mut self, token: Token, events: Ready); fn close(&mut self); fn timeout(&mut self, t: Token) -> bool; fn last_event(&self) -> Instant; fn print_session(&self); fn frontend_token(&self) -> Token; fn shutting_down(&mut self) -> bool; // Provided methods fn cluster_id(&self) -> Option<ClusterId> { ... } fn session_address(&self) -> Option<SocketAddr> { ... } fn needs_ready_pass(&self) -> bool { ... } fn yielded(&mut self) -> bool { ... } fn targets(&self, _target: &SessionTarget) -> bool { ... }
}
Expand description

trait that must be implemented by listeners and client sessions

Required Methods§

Source

fn protocol(&self) -> Protocol

indicates the protocol associated with the session

this is used to distinguish sessions from listenrs, channels, metrics and timers

Source

fn ready(&mut self, session: Rc<RefCell<dyn ProxySession>>) -> bool

if a session received an event or can still execute, the event loop will call this method. Its result indicates if it can still execute, needs to connect to a backend server, close the session

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 on the session

Source

fn close(&mut self)

close a session, frontend and backend sockets, remove the entries from the session manager slab

Source

fn timeout(&mut self, t: Token) -> bool

if a timeout associated with the session triggers, the event loop will call this method with the timeout’s token

Source

fn last_event(&self) -> Instant

last time the session got an event

Source

fn print_session(&self)

display the session’s internal state (for debugging purpose)

Source

fn frontend_token(&self) -> Token

get the token associated with the frontend

Source

fn shutting_down(&mut self) -> bool

tell the session it has to shut down if possible

if the session handles HTTP requests, it will not close until the response is completely sent back to the client

Provided Methods§

Source

fn cluster_id(&self) -> Option<ClusterId>

Best-effort identifier of the cluster currently routed to by this session. Returns None for ListenSession (no per-session cluster), and for client sessions before routing has resolved. H2 sessions multiplex many streams over one frontend token and may touch several clusters; the returned value is whichever cluster the session most recently keep-alive’d to. Used for log/metric attribution, not for accounting (the tracker keeps the canonical per-stream (cluster, IP) set).

Source

fn session_address(&self) -> Option<SocketAddr>

Source address as observed by Sōzu, with proxy-protocol awareness. HTTP/HTTPS/TCP client sessions return the parsed PROXY-protocol source when present, else peer_addr. ListenSession returns None. Used to attribute per-(cluster, source-IP) tracking and access logs to the real client behind a layer-4 PROXY frontend.

Source

fn needs_ready_pass(&self) -> bool

Whether the session has work that only a Self::ready pass can do although no socket event will arrive to trigger one.

Asked by Server::timeout after a timeout that left the session open. A backend whose connect timed out is the case: the timer is the only signal a blackholed dial ever produces, and failing it over to another backend (dialling, registering the new socket) needs the ready path (sozu-proxy/sozu#1800).

Source

fn yielded(&mut self) -> bool

Whether the last Self::ready pass stopped at its iteration budget while still forwarding bytes, with work left that no socket event will announce again. Reading it clears it.

Server::ready and Server::timeout queue such a session, and Server::resume_yielded_sessions runs its ready pass again after the next poll, so a fast transfer neither holds the single-threaded worker nor stalls (sozu-proxy/sozu#1906). Only the mux-backed HTTP and HTTPS sessions yield.

Source

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

Whether this session holds a backend connection target names, which makes it one of the sessions a CloseSessions request closes.

false for listeners, channels and every session that has no backend connection yet, such as one still in its TLS handshake.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§