* Initial compression support
* Support configuring compression on `Server`
* Minor clean up
* Test that compression is actually happening
* Clean up some todos
* channels compressing requests
* Move compression to be on the codecs
* Test sending compressed request to server that doesn't support it
* Clean up a bit
* Compress server streams
* Compress client streams
* Bidirectional streaming compression
* Handle receiving unsupported encoding
* Clean up
* Add note to future self
* Support disabling compression for individual responses
* Add docs
* Add compression examples
* Disable compression behind feature flag
* Add some docs
* Make flate2 optional dependency
* Fix docs wording
* Format
* Reply with which encodings are supported
* Convert tests to use mocked io
* Fix lints
* Use separate counters
* Don't make a long stream
* Address review feedback
Adds `tonic::Extensions` which is a newtype around `http::Extensions`.
Request extensions can be set by interceptors with
`Request::extensions_mut` and retrieved from RPCs with
`Request::extensions`. Extensions can also be set in tower middleware
and will be carried through to the RPC.
Since response extensions cannot be set by interceptors the main use
case is to set them in RPCs and retrieve them in tower middlewares.
Figured that might be useful.
Fixes https://github.com/hyperium/tonic/issues/255
* transport: Support timeouts with "grpc-timeout" header
* Apply suggestions from code review
Co-authored-by: Lucio Franco <[email protected]>
* Timeout -> GrpcTimeout and export TimeoutExpired
* Clean up imports
* Give header name a more proper home
* Add fuzz tests for parsing header value into `grpc-timeout`
* Map `TimeoutExpired` to `cancelled` status
* Recover from timeout errors in the service
* Refactor tests
* Fix CI
* Fix CI, again
Co-authored-by: Lucio Franco <[email protected]>
* Upgrade Tonic to Tokio 1.0
Work in progress for updating Tonic to Tokio 1.0. Since tower has not
been released to crates.io, a git dependency is taken instead.
* Upgrade Tonic to Tokio 1.0 phase 2
* tonic: remove tower-* deps
* Apply suggestions from code review
Co-authored-by: Ed Marshall <[email protected]>
Co-authored-by: Lucio Franco <[email protected]>
* fix(transport): reconnect lazy connections after first failure
Channels created with lazy connections never try to reconnect if the
first connection attempt fails. This is because `Reconnect` returns
`Poll::Ready(Err)` on poll_ready and the service is considered dead.
This change passes a flag to Reconnect to signal if the connection
is intended to be lazy, in which case reconnect returns the error on
the next call.
fixes#452
Before this fix, if the connect phase of the transport failed before
ever establishing a connection, we would never return the error until
the first call to send a request. This PR changes that behavior to only
forward the error to the call method if we have ever made a connection
before. If we have never established a connection before then
`Reconnect` will return an error on the call to `poll_ready`.
Fixes#403
When calling methods on Arc<MyService> where the method is also defined on Arc (e.g. drop and clone), calling inner.#method_ident(request) will actually attempt to call the Arc method instead of the method on the service, resulting in a compile error. This change removes the ambiguity by dereferencing the inner Arc.
* don't replace extern_path'd paths
tonic-build will replace all paths except for google well known types
with one rooted at the super module. For paths that have already been
replaced with a fully qualified path via the extern_path config option,
(e.g. "::uuid::Uuid"), this results in an invalid path
(e.g. "super::::uuid::Uuid"), and a build failure. These paths should
also be excluded when prefixing relative modules with super.
* add doc in tonic-build clarifying extern_path
extern_path expects fully qualified proto and rust paths
* add test cast case for extern path fix
add a test that extern path does indeed result in service types using
the specified type from an external crate. we test this by creating a
service type that has a proto from a different crate, and asserting that
it does indeed impl a trait from that crate
* add license/publish to extern_path test crates