This implements an option to emit `Arc<Self>` instead of `&self` in
server traits. This enables implementor to reference `Self` data for
indefinite duration, which may be useful for streaming requests.
Fixes: #1351
* 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
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.
This commit adds a new crate `tonic-health` which implements the
[standard GRPC Health Checking][checking] protocol.
Currently there is only a server implementation, though others have
alluded in the discussion in #135 that client implementations exist
which could also be imported as necessary.
A example server has also been added - once the client work is done a
client for this should be added also.
[checking]: https://github.com/grpc/grpc/blob/master/doc/health-checking.mdFixes#135.
* 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
This change introduces proper gRPC interceptors that are avilable
regardless of the transport used. Each codegen service now produces an
additional method called `with_interceptor` that accepts a
`Interceptor`.
All examples have been updated to use this new style and interop has a
custom `tower::Service` middleware to echo the headers. There is also a
new `interceptor` example that shows basic usage.
BREAKING CHANGE: removed `interceptor_fn` and `intercep_headers_fn` from `transport` in favor of using `tonic::Interceptor`.
* fix(build): Prevent duplicated client/server generated code
The tonic-build process collects up RPC services as they are provided by
prost, before writing them out as part of the finalization step for a
given protocol buffer package.
In the case of imported protocol buffer packages, there may be RPC
services included by import in addition to those in the top-level
package. Therefore it is necessary to make sure each set of
client/server services gathered by tonic-build is cleared after the
finalization process for a given protocol buffer package, otherwise they
will be incorrectly aggregated as the generation process proceeds
through the subsequent packages.
* Test case for duplicated client/server generated code
A simple test case that will fail to build without a fix to prevent
RPC services being duplicated into inappropriate modules (that related
to particular protocol buffer packages).
* Additional test case for included_service
Introduces an additional case that captures making sure services defined
before including a package with additional services doesn't
incidentially clear such precursor services from the including package.
* Fix unnecessary newline to keep `cargo fmt` happy