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§
Sourcefn ready(
&mut self,
session: Rc<RefCell<dyn ProxySession>>,
proxy: Rc<RefCell<dyn L7Proxy>>,
metrics: &mut SessionMetrics,
) -> SessionResult
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
Sourcefn update_readiness(&mut self, token: Token, events: Ready)
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
Sourcefn timeout(&mut self, token: Token, metrics: &mut SessionMetrics) -> StateResult
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
Sourcefn cancel_timeouts(&mut self)
fn cancel_timeouts(&mut self)
cancel frontend timeout (and backend timeout if present)
Sourcefn print_state(&self, context: &str)
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§
Sourcefn close(
&mut self,
_proxy: Rc<RefCell<dyn L7Proxy>>,
_metrics: &mut SessionMetrics,
)
fn close( &mut self, _proxy: Rc<RefCell<dyn L7Proxy>>, _metrics: &mut SessionMetrics, )
close the state
Sourcefn shutting_down(&mut self) -> bool
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