`Code` is already trivial to convert into an `i32` however that isn't
immediately obvious by looking at the docs. This has tripped me up
before.
Implementing `From<Code>` for `i32` should hopefully make it a bit more
obvious.
Sometimes error output from rustfmt might be printed to stdout instead
of stderr. So to help users debug rustfmt issues this makes stdout get
printed as well.
Fixes https://github.com/hyperium/tonic/issues/600
Doing
```rust
let clone = self.inner.clone();
Box::pin(async move {
let response = clone.call(request).await?;
Ok(response)
})
```
If `self.inner` is (or contains) a `tower::buffer::Buffer` might panic.
That is because cloning a `Buffer` drops the permit that was acquired in
`poll_ready`, meaning it is no longer ready and panic in `call`.
The solution is to use `mem::replace` to take the ready service and pass
that into the async block.
Fixes https://github.com/hyperium/tonic/issues/545
* 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]>
* Use new tower utilities
Tower recently introduced `layer_fn` and `ServiceBuilder::option_layer`.
Some very similar things existed in Tonic. This replaces those with what
Tower provides.
* Also use `ServiceBuilder::layer_fn`
This is particularly handy when combined with `clap::value_t`.
Here's demo of it working with Clap:
```bash
cargo +stable init --bin tonic-demo
cd tonic-demo
cat <<-EOF >> Cargo.toml
clap = "*"
tonic = { path = "../hyperium/tonic/tonic" }
EOF
cat <<-EOF > src/main.rs
use clap::{value_t, App, Arg};
use tonic::transport::Endpoint;
fn main() {
let matches = App::new("tonic-demo")
.arg(Arg::with_name("host"))
.get_matches();
let x = value_t!(matches.value_of("host"), Endpoint);
println!("{:?}", x);
}
EOF
cargo +stable run -- https://127.0.0.1:443
```
Signed-off-by: Ana Hobden <[email protected]>
In tower 0.4.0 we missed a couple of re-exports that tonic 0.4.0 depends
on. So tonic really depends on tower at least version 0.4.1. Since
specifying your tower depedency as 0.4 means you might get 0.4.0, you
might get build errors when updating tonic. Such as [#553] and [#552].
This fixes that by bumping tonic's dependency on tower to 0.4.4. That
means users will get at least tower version 0.4.4, but semver compatible
updates are still allowed.
Fixes https://github.com/hyperium/tonic/issues/553
[#553]: https://github.com/hyperium/tonic/issues/553
[#552]: https://github.com/hyperium/tonic/issues/552
Bumps routeguide tutorial dependency to tokio 1.0 for compatability with
tonic 0.4. Also adds required rt-multi-thread feature and drops unused
and now unsupported stream feature.
Signed-off-by: hasheddan <[email protected]>
* fix(transport): return Poll::ready until error is consumed
When a lazy connection fails to connect it first
returns Poll::ready from the reconnect service,
yet the subsequent call returns Poll::pending
making tower_balance loop forever.
Instead, on error we return Ready
until the error is consumed in the
call method.
* chore: revert version change
* refactor: Into<Error> bounds for error intead of debug
* Remove fmt::Debug bound for reconnect
Co-authored-by: Helge Hoff <[email protected]>
* tonic: add max http2 frame size to server.
Exposes option to configure the max http2 frame size used by the
underlying hyper server via the `tonic::transport::Server` builder.
Refs: #264
* fix http2_* methods broken in merge conflict
* 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]>
Instead of failing and bailing when a bad cert is found, ignore one-off
errors for bad certs and continue to load the rest of the store.
These one-off errors mostly affect MacOS users, as found in this
rustls-native-certs issue: https://github.com/ctz/rustls-native-certs/issues/4Fixes: #519