1 unstable release
new 0.2.0 | Dec 9, 2024 |
---|
#529 in Asynchronous
63 downloads per month
Used in streamstore
13KB
99 lines
tonic-side-effect
This crate provides a tower service for wrapping a tonic Channel, which monitors if a request Body ever produced a frame before returning an error.
The service communicates whether poll_frame
on the request ever produced data, via a handle to shared state.
Why might this be helpful?
It can be useful, when building systems that need to carefully consider potential side-effects from RPCs, to disambiguate between failures which occurred strictly before any data from a request could possibly have been read (as might be the case for a connection refused or DNS error), and failures which occurred after request data may have been consumed (e.g. a connection reset).
A tonic Status represents the mapping of many types of underlying failures into gRPC status, and it's not possible to make hard guarantees about whether any request content was transmitted or not simply by considering the status code.
This service provides more direct access to a boundary that is of particular interest for purposes of reasoning about RPC side-effects (and in a safer way than rooting around in the status' error source chain).
Dependencies
~5–12MB
~126K SLoC