Commit Graph
243 Commits
Author SHA1 Message Date
David PedersenandGitHub dae31d0e1c feat(tonic): Add Request::set_timeout (#615)
* feat(tonic): Add `Request::set_timeout`

This will set the `grpc-timeout`.

* Expand docs a bit
2021-04-29 15:59:08 +02:00
David PedersenandGitHub 4001665821 chore: Add deny(broken_intra_doc_links) to all crates (#616) 2021-04-29 15:57:21 +02:00
9ff4f7b8e4 feat(transport): Support timeouts with "grpc-timeout" header (#606)
* 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]>
2021-04-29 10:28:16 +02:00
Juan AlvarezandGitHub b04c1c6582 configure tls automatically when possible (#445) 2021-04-23 10:42:01 -04:00
David PedersenandGitHub d414206736 Use new tower utilities (#560)
* 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`
2021-04-14 09:26:49 +02:00
Lucio FrancoandGitHub 8fa6daae92 chore: Prepare tonic 0.4.2 and health 0.3.1 (#605) 2021-04-13 18:20:13 -04:00
Lucio Franco 7aaa2f85d9 Revert "Remove grpc-timeout header from reserved headers (#603)"
This reverts commit 0b535985c8.
2021-04-13 21:59:16 +00:00
Fuyang LiuandGitHub 0b535985c8 Remove grpc-timeout header from reserved headers (#603) 2021-04-13 09:28:02 +02:00
Joel HönerandGitHub 1d2754feba fix(codec): Allocate inbound buffer once (#578)
Gets rid of reallocs when receiving large messages, increasing throughput by about 30%-40%.
2021-04-07 19:34:12 -04:00
Tom DyasandGitHub 0d05aa0d02 feat: Expose status constructors (#579) 2021-04-07 17:39:05 -04:00
Dirkjan OchtmanandGitHub 380049daf8 Improve comment on Channel::builder() (#597) 2021-04-07 14:26:33 +02:00
Ben SullyandGitHub 6c898a239f Use fully qualified path for futures_core::Stream in codegen (#591) 2021-03-28 19:31:20 +02:00
Greg MeltonandGitHub 2788628916 Fix Prost codec tests and cfg (#584) 2021-03-20 18:07:01 +01:00
David PedersenandGitHub 7889c7ff97 Prepare 0.4.1 release (#580) 2021-03-16 17:39:57 +01:00
Hirochika MatsumotoandGitHub 49d517fac9 Remove unneeded backquote (#564) 2021-02-17 11:28:28 +01:00
c54f24721c feat: Implement gRPC Reflection Service (#340)
Co-authored-by: Samani G. Gikandi <[email protected]>
2021-02-16 11:07:51 -05:00
Ana HobdenandGitHub f49d4bdf99 chore: add FromStr for Endpoint (#558)
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]>
2021-02-13 20:49:10 +01:00
David PedersenandGitHub ca3b9a1df1 fix: Depend on at least tower 0.4.4 (#554)
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
2021-02-12 10:58:54 -05:00
Lucio FrancoandGitHub fda2d689d4 chore: Prepare 0.4 release (#538)
* Prepare `0.4` release

* Fix cargo issues
2021-01-15 13:38:36 -05:00
Lucio FrancoandGitHub a7778ad166 feat(transport): Move error! to debug! (#537) 2021-01-15 12:51:28 -05:00
dafea9adee fix(transport): return Poll::ready until error is consumed (#536)
* 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]>
2021-01-15 12:34:41 -05:00
CameronandGitHub 31936e0513 feat(transport): add max http2 frame size to server. (#529)
* 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
2021-01-15 12:00:01 -05:00
Lucio FrancoandGitHub 41c51f1c61 feat(transport): Fix TLS accept w/ peer certs (#535)
* feat(transport): Fix TLS accept w/ peer certs

* fix unused var

* fix feature flag imports

* spawn accept task
2021-01-15 11:59:26 -05:00
fdda5ae26a Upgrade to Tokio 1.0.0 ecosystem (#530)
* 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]>
2021-01-11 12:18:34 -05:00
Alex PearsonandGitHub fe4d5b9d9a fix: gracefully handle bad native certs (#520)
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/4

Fixes: #519
2021-01-07 10:52:13 -05:00
CameronandGitHub a6be8363ed Add h2 error conversion for Status (#509) 2021-01-05 16:04:15 -05:00
CameronandGitHub 6622bb1449 Update tonic logo (#508)
* Use fancy new logo

* Remove shell.nix
2021-01-05 16:03:33 -05:00
Julian PopescuandGitHub fc86563b36 feat(tonic): implement From<io::Error> for Status (#500)
Implements the conversion from `std::io::Error` to `tonic::Status`.

**Motivation:** The `io::Error` conversion is currently left as
unimplemented. It either should be implemented or removed if it won't be
implemented.

**Solution:** Implements the conversion from `std::io::Error` to
`tonic::Status`
2021-01-05 16:00:08 -05:00
Koki KatoandGitHub e7be352132 transport: impl Service for Channel instead of GrpcService (#482)
* transport: impl Service for Channel instead of GrpcService

This adds tower::Service impl for tonic::transport::Channel
and removes GrpcService impl declaration.

Channel still implements GrpcService, thanks to the general
impl declaration of GrpcService for types who implement Service.

Fixes #481.

* examples: stop using GrpcService to avoid ambiguity

* examples: add timeout example
2021-01-05 13:36:18 -05:00
Pedro CaladoandGitHub 2b9cdb9779 feat(transport): expose HTTP2 server keepalive interval and timeout (#486)
Adds two methods to `transport::server::Server` for setting HTTP2 server
keepalive interval and timeout as exposed by `hyper::server::Builder`.

Fixes #474
2021-01-05 13:35:45 -05:00
Jake GouldingandGitHub f58fcf31d1 Merge trailer and inital headers into status on err (#510)
The C++ gRPC server sometimes returns both headers and trailers. An
excerpt from Wireshark:

```
Stream: HEADERS, Stream ID: 1, Length 136, 200 OK
    Header: :status: 200 OK
    Header: x-middleware: expected value
    Header: content-type: application/grpc
    Header: grpc-accept-encoding: identity,deflate,gzip
    Header: accept-encoding: identity,gzip

Stream: HEADERS, Stream ID: 1, Length 92
    Header: grpc-status: 2
    Header: grpc-message: Unknown
    Header: x-arrow-status: 9
    Header: x-arrow-status-message-bin: VW5rbm93bg
```

Before this commit, only the metadata from the trailer would be
available, missing the `x-middleware` header:

```
MetadataMap {
    headers: {
        "x-arrow-status-message-bin": "VW5rbm93bg",
        "x-arrow-status": "9",
    },
}
```
2020-12-14 14:20:15 -05:00
Luca PalmieriandGitHub 2e964c78c6 feat(transport): Connect lazily in the load balanced channel (#493) 2020-11-18 14:26:49 -05:00
Juan AlvarezandGitHub f1275b611e chore: fix warnings in metadata module (#468) 2020-10-08 09:00:10 -05:00
Juan AlvarezandGitHub 0c69c378fd chore: clippy lints (#467)
* chore: clippy lints
2020-09-29 14:38:49 -05:00
Juan AlvarezandGitHub d4899df832 feat(transport): add user-agent header to client requests. (#457)
* Add a default user-agent header to outgoing requests.
* The user agent can be configured through the `Channel` builder.

fixes #453
2020-09-23 18:58:03 -05:00
Juan AlvarezandGitHub e9910d10a7 fix(transport): reconnect lazy connections after first failure (#458)
* 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
2020-09-23 09:35:42 -05:00
c7fd9d4586 chore(docs): Fix ClientTlsConfig::domain_name docs (#449)
Co-authored-by: Eric Lin <[email protected]>
2020-09-07 10:56:50 -05:00
Juan AlvarezandGitHub 26ce9d12bf fix(transport) Do not panic when building and Endpoint with an invali… (#438)
BREAKING CHANGE: `TryFrom` API has been changed.
2020-08-31 10:02:40 -04:00
594a542b8a fix(transport): Add content-type for Unimplemented (#434)
Co-authored-by: Lucio Franco <[email protected]>
2020-08-21 10:42:41 -04:00
bec4936daf doc(transport): improve connect_with_connector doc (#432)
Co-authored-by: Lucio Franco <[email protected]>
2020-08-20 16:14:35 -04:00
37f6733f85 feat(transport): Add Router::into_service (#419)
Co-authored-by: Danny Hua <[email protected]>
2020-08-20 15:11:31 -04:00
Lucio FrancoandGitHub 90858926b6 chore: Prepare 0.3.1 release (#436) 2020-08-20 10:49:12 -04:00
Lucio FrancoandGitHub 2ea17b2ecf fix(transport): Return connection error on Channel::connect (#413)
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
2020-07-27 12:44:11 -04:00
Harry BarberandGitHub 5bd8a04baf Fix typo (#405) 2020-07-27 12:33:24 -04:00
L1AN0andGitHub 96db606908 Fix typo in doc. (#398) 2020-07-14 16:41:39 -04:00
Lucio FrancoandGitHub 62b8ab0b51 chore: Prepare 0.3.0 release (#399)
* chore: Prepare 0.3.0 release

* update changelog

* fix builds

* Update breaking changes
2020-07-13 13:00:54 -04:00
Kaleb ElwertandGitHub 570c606397 chore: Upgrade base64 and tokio-rustls packages (#397) 2020-07-10 23:10:15 -05:00
Lucio FrancoandGitHub a567f17e52 chore: Prepare 0.2.2 release (#396) 2020-07-10 12:59:22 -04:00
Lucio FrancoandGitHub 2c4c544d90 fix: Status::details leaking base64 encoding (#395)
Fixes #379
2020-07-10 12:40:55 -04:00
Harry BarberandGitHub 2b997b0c5f feat(transport): Add optional service methods (#275) 2020-07-10 12:39:52 -04:00