Skip to main content

Connection

Enum Connection 

Source
pub enum Connection<Front: SocketHandler> {
    H1(ConnectionH1<Front>),
    H2(H2Shell<Front>),
}

Variants§

§

H1(ConnectionH1<Front>)

§

H2(H2Shell<Front>)

Implementations§

Source§

impl<Front: SocketHandler> Connection<Front>

Source

pub fn new_h1_server( session_ulid: Ulid, front_stream: Front, timeout_duration: Duration, ) -> Connection<Front>

Source

pub fn new_h1_client( session_ulid: Ulid, front_stream: Front, cluster_id: ClusterId, backend: BackendId, timeout_duration: Duration, ) -> Connection<Front>

Source

pub fn new_h2_server( session_ulid: Ulid, front_stream: Front, buffers: &mut dyn BufferSource, timeout_duration: Duration, flood_config: H2FloodConfig, connection_config: H2ConnectionConfig, stream_idle_timeout: Duration, graceful_shutdown_deadline: Option<Duration>, ) -> Option<Connection<Front>>

Source

pub fn new_h2_client( session_ulid: Ulid, front_stream: Front, cluster_id: ClusterId, backend: BackendId, buffers: &mut dyn BufferSource, timeout_duration: Duration, flood_config: H2FloodConfig, connection_config: H2ConnectionConfig, stream_idle_timeout: Duration, graceful_shutdown_deadline: Option<Duration>, ) -> Option<Connection<Front>>

Source

pub fn readiness(&self) -> &Readiness

Source

pub fn readiness_mut(&mut self) -> &mut Readiness

Source

pub fn position(&self) -> &Position

Source

pub fn peer_closed(&self) -> bool

Whether the peer has closed its side of this connection: its readiness carries Ready::HUP, recorded by epoll (EPOLLRDHUP/EPOLLHUP, see Ready::from(&mio::event::Event)) or, on an H1 backend, by a read that met the EOF or a reset (ConnectionH1::readable).

A backend that sozu itself is dropping does not count: force_disconnect writes HUP into the readiness of a live backend and marks it BackendStatus::Disconnecting, so that state is excluded and its peer keeps its shutdown(SHUT_WR) (see mux::shutdown_write).

Source

pub fn position_mut(&mut self) -> &mut Position

Source

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

Source

pub fn socket_mut(&mut self) -> &mut TcpStream ⓘ

Source

pub fn socket_handler_mut(&mut self) -> &mut Front

The socket handler itself, for what only it knows how to record: FrontRustls::readiness_delivered (lib/src/https.rs).

Source

pub fn peer_address(&self) -> Option<SocketAddr>

The peer address this connection snapshotted at construction — ConnectionH1::peer_address / ConnectionH2::peer_address, the single SocketHandler::peer_addr read taken on its whole lifetime.

The one accessor Mux’s own log macros were missing. Without it the only route from a Connection to a peer address was socket, which hands back a concrete &mio::net::TcpStream whose inherent peer_addr wins method resolution over the trait — a live getpeername(2) that answers ENOTCONN once the peer resets and reports the transport source rather than a PROXY-advertised client. So a MUX line disagreed with the MUX-H1 / MUX-H2 / SOCKET / HTTPS lines of the very same session.

Reads the field rather than calling the trait again, so rendering a MUX line costs no socket access at all and cannot drift from what the per-protocol envelopes print for the same session.

This is the sole reader of ConnectionH2::peer_address outside lib/src/protocol/mux/h2.rs, and the only reason that field is pub(super) rather than private — the visibility ConnectionH1::peer_address already carried.

Source

pub fn poll_timeout(&self) -> Option<Instant>

The next instant this connection wants timeout() called at, or None for “no timer”.

This replaced timeout_container(), which handed the caller the wheel handle itself. The cores no longer own one: they publish a deadline and the Mux adapter owns every TimeoutContainer, so there is exactly one place that talks to crate::timer and exactly one place that can get the arm / re-arm discipline wrong. See LIFECYCLE.md §7.7.

Source

pub fn timeout_duration(&self) -> Duration

The configured idle timeout, carried so the adapter’s container keeps a current duration() for whoever inherits it (the WebSocket upgrade hands it to Pipe, which re-arms from it).

Source

pub fn arm_timeout(&mut self, now: Instant)

Push the deadline one full duration out from now. Replaces timeout_container().set(token) / .reset() at the adapter’s sites.

Source

pub fn clear_timeout(&mut self)

Ask for no timer at all. Replaces timeout_container().cancel().

Source

pub fn set_timeout_duration(&mut self, duration: Duration, now: Instant)

Adopt a new configured duration and re-arm from now. Replaces timeout_container().set_duration(d).

Source

pub fn overhead_bytes(&self) -> (usize, usize)

Returns connection-level byte overhead (bin, bout) for H2, (0, 0) for H1.

Trait Implementations§

Source§

impl<Front: Debug + SocketHandler> Debug for Connection<Front>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Front> !Freeze for Connection<Front>

§

impl<Front> !RefUnwindSafe for Connection<Front>

§

impl<Front> !Send for Connection<Front>

§

impl<Front> !Sync for Connection<Front>

§

impl<Front> !UnwindSafe for Connection<Front>

§

impl<Front> Unpin for Connection<Front>
where ConnectionH1<Front>: Unpin, H2Shell<Front>: Unpin,

§

impl<Front> UnsafeUnpin for Connection<Front>

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.