Trait SessionState

Source
pub trait SessionState {
    // Required methods
    fn ready(
        &mut self,
        session: Rc<RefCell<dyn ProxySession>>,
        proxy: Rc<RefCell<dyn L7Proxy>>,
        metrics: &mut SessionMetrics,
    ) -> SessionResult;
    fn update_readiness(&mut self, token: Token, events: Ready);
    fn timeout(
        &mut self,
        token: Token,
        metrics: &mut SessionMetrics,
    ) -> StateResult;
    fn cancel_timeouts(&mut self);
    fn print_state(&self, context: &str);

    // Provided methods
    fn close(
        &mut self,
        _proxy: Rc<RefCell<dyn L7Proxy>>,
        _metrics: &mut SessionMetrics,
    ) { ... }
    fn shutting_down(&mut self) -> bool { ... }
}
Expand description

All States should satisfy this trait in order to receive and handle Session events

Required Methods§

Source

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

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 or if the session can be closed

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 timeout(&mut self, token: Token, metrics: &mut SessionMetrics) -> StateResult

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

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),

<context> Session(<State name>):
    Frontend:
        - Token(...) Readiness(...)
    Backends:
        - Token(...) Readiness(...)
        - Token(...) Readiness(...)

Provided Methods§

Source

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

close the state

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

Implementors§