pub struct TransactionLayer { /* private fields */ }Expand description
Holds the transactions in flight and routes messages to them.
Sans-IO like everything beneath it: the driver feeds messages and fired timers in, and performs the outputs.
Implementations§
Source§impl TransactionLayer
impl TransactionLayer
Sourcepub fn len(&self) -> (usize, usize)
pub fn len(&self) -> (usize, usize)
How many transactions are in flight, as (client, server).
Exposed because a transaction store that leaks is a slow, quiet outage, and a test that asserts on this is the cheapest way to notice.
Sourcepub fn send_request(
&mut self,
request: Request,
reliability: Reliability,
) -> Option<(TransactionKey, Vec<Output>)>
pub fn send_request( &mut self, request: Request, reliability: Reliability, ) -> Option<(TransactionKey, Vec<Output>)>
Send a request, creating a client transaction for it.
Sourcepub fn receive(
&mut self,
message: Message,
reliability: Reliability,
) -> Dispatch
pub fn receive( &mut self, message: Message, reliability: Reliability, ) -> Dispatch
Route an incoming message.
Sourcepub fn send_response(
&mut self,
key: &TransactionKey,
response: Response,
) -> Vec<Output>
pub fn send_response( &mut self, key: &TransactionKey, response: Response, ) -> Vec<Output>
Send a response from the transaction user.
Sourcepub fn abandon(&mut self, key: &TransactionKey) -> bool
pub fn abandon(&mut self, key: &TransactionKey) -> bool
Abandon a server transaction the transaction user never answered.
RFC 3261 §17.2 gives a server transaction in Trying no timer, because the model is
that the transaction user always responds. A stack exposed to a network needs the case
where it does not: an application that forgot a request, or one that is wedged, both
look like this, and a transaction held for the life of the process is a leak that grows
with traffic.
Deliberately not a timer inside the transaction: that would change what the state machine does, and the machine is right. This is the layer above admitting that its user is fallible, and it is the driver — which owns the clock — that decides when.
Returns whether there was one to abandon.
Sourcepub fn on_timer(&mut self, key: &TransactionKey, timer: Timer) -> Vec<Output>
pub fn on_timer(&mut self, key: &TransactionKey, timer: Timer) -> Vec<Output>
A timer fired for a transaction.
Sourcepub fn on_transport_error(&mut self, key: &TransactionKey) -> Vec<Output>
pub fn on_transport_error(&mut self, key: &TransactionKey) -> Vec<Output>
The transport failed for a transaction.
Sourcepub fn server_request(&self, key: &TransactionKey) -> Option<&Request>
pub fn server_request(&self, key: &TransactionKey) -> Option<&Request>
The request that created a server transaction.
A driver needs this to build a response on the transaction’s behalf — refusing an overloaded endpoint with 503, for instance — without the application having been given the request in the first place.
Sourcepub fn client_request(&self, key: &TransactionKey) -> Option<&Request>
pub fn client_request(&self, key: &TransactionKey) -> Option<&Request>
The request that created a client transaction.
A transport driver needs this after an asynchronous connection attempt fails so it can account for the exact method whose queued bytes never reached a socket.
Sourcepub fn client_state(&self, key: &TransactionKey) -> Option<ClientState>
pub fn client_state(&self, key: &TransactionKey) -> Option<ClientState>
The state of a client transaction, if it exists.
Sourcepub fn server_state(&self, key: &TransactionKey) -> Option<ServerState>
pub fn server_state(&self, key: &TransactionKey) -> Option<ServerState>
The state of a server transaction, if it exists.