Skip to main content

SniPreread

Struct SniPreread 

Source
pub struct SniPreread<Front: SocketHandler> {
    pub frontend: Front,
    pub frontend_token: Token,
    pub frontend_readiness: Readiness,
    pub backend_readiness: Readiness,
    pub backend: Option<TcpStream>,
    pub backend_token: Option<Token>,
    pub request_id: Ulid,
    pub frontend_buffer: Checkout,
    /* private fields */
}
Expand description

TCP session state that owns the frontend socket and the accumulating Checkout while SniPrereadCore decides a route. See the module doc for the full lifecycle and the exit-accounting contract for tcp.sni_preread.active.

Fields§

§frontend: Front§frontend_token: Token§frontend_readiness: Readiness§backend_readiness: Readiness§backend: Option<TcpStream>§backend_token: Option<Token>§request_id: Ulid§frontend_buffer: Checkout

The session’s own frontend accumulator, growing from wire offset 0. NEVER consume()d while undecided.

Implementations§

Source§

impl<Front: SocketHandler> SniPreread<Front>

Source

pub fn new( frontend: Front, frontend_token: Token, request_id: Ulid, frontend_buffer: Checkout, effective_max_bytes: usize, ) -> Self

Instantiate a new SniPreread SessionState with:

  • frontend_interest: READABLE | HUP | ERROR
  • backend_interest: HUP | ERROR (WRITABLE armed once routed)
Source

pub fn effective_max_bytes(&self) -> usize

Source

pub fn outcome(&self) -> Option<&RoutedOutcome>

Source

pub fn is_routed(&self) -> bool

Source

pub fn started_at(&self) -> Instant

Source

pub fn has_received_bytes(&self) -> bool

Bytes already accumulated from the frontend. Distinguishes a genuine mid-preread abort (bytes were seen) from a bare TCP health-check connect/FIN with no bytes at all (cf. expect.rs’s identical guard).

Source

pub fn front_socket(&self) -> &TcpStream

Source

pub fn back_socket_mut(&mut self) -> Option<&mut TcpStream>

Source

pub fn set_back_socket(&mut self, socket: TcpStream)

Source

pub fn set_back_token(&mut self, token: Token)

Source

pub fn readable( &mut self, metrics: &mut SessionMetrics, cfg: &PrereadConfig<'_>, ) -> SessionResult

Read available bytes and feed them to the core. Emits the tcp.sni_preread.routed / tcp.sni_preread.rejected.<reason> metrics and log lines itself; the caller (TcpSession::readable in lib/src/tcp.rs) only needs to react to the returned SessionResult and, on a fresh route, sync TcpSession::cluster_id from Self::outcome.

Source

pub fn on_timeout(&mut self, cfg: &PrereadConfig<'_>)

Feed the preread deadline firing. Always terminal: a fired deadline resolves to Reject(Fragmented) (or replays an already-latched verdict in the vanishingly unlikely race where routing and the deadline land in the same tick – the core’s decided latch makes that safe either way).

Source

pub fn on_front_closed(&mut self, cfg: &PrereadConfig<'_>)

Feed a frontend close observed before a routing decision (e.g. HUP racing ahead of readable’s own 0-byte detection, dispatched from TcpSession::front_hup). Mirrors readable’s SocketResult::Closed handling: silent when no bytes were ever received (the bare TCP health-check pattern), metered otherwise.

Source

pub fn back_writable(&self) -> SessionResult

The back_writable dispatch point: only ever reachable once routed – the not-yet-routed guard in TcpSession::attempt_backend_connect_if_needed (lib/src/tcp.rs, both call sites inside ready_inner) guarantees connect_to_backend (and therefore any backend-writable event) never runs before a route decision. The actual per-ProxyProtocolConfig dispatch lives in TcpSession::upgrade_sni_preread (it needs the TcpProxy/listener context this struct deliberately does not hold), so this just signals the transition.

Auto Trait Implementations§

§

impl<Front> !Freeze for SniPreread<Front>

§

impl<Front> !RefUnwindSafe for SniPreread<Front>

§

impl<Front> !UnwindSafe for SniPreread<Front>

§

impl<Front> Send for SniPreread<Front>
where Front: Send,

§

impl<Front> Sync for SniPreread<Front>
where Front: Sync,

§

impl<Front> Unpin for SniPreread<Front>
where Front: Unpin,

§

impl<Front> UnsafeUnpin for SniPreread<Front>
where Front: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more