Commit Graph
49 Commits
Author SHA1 Message Date
David PedersenandGitHub 542c5b37dc chore: update to axum 0.6.0 (#1155) 2022-11-28 10:40:46 -05:00
David PedersenandGitHub ee3d0dfe75 feat(tonic): impl Clone for Status using Arc (#1076) 2022-09-12 11:31:30 -04:00
David PedersenandGitHub 13b55df1d0 chore: update tower-http (#985)
* Update tower-http

* one more update
2022-04-27 15:14:55 +02:00
David PedersenandGitHub d142e1aa4c chore: update to axum 0.5 (#953) 2022-03-31 21:57:16 +02:00
David PedersenandGitHub 0859d82e57 feat(transport): support customizing Channel's async executor (#935) 2022-03-15 11:11:44 -07:00
David PedersenandGitHub 6dfc20e1db feat(transport): port router to axum (#830) 2022-02-18 18:19:52 +01:00
David PedersenandGitHub e78a2d832f chore: Prepare 0.6.2 (#860)
- Contains the revert to [rust 2018](https://github.com/hyperium/tonic/pull/847).
- Bumps both tonic and tonic-build.
- tonic-build goes from 0.6.0 to 0.6.2 since there was no 0.6.1. I
  believe we want tonic and tonic-build versions to follow each other.
2021-12-08 17:42:16 +01:00
David PedersenandGitHub 101f2f76d4 chore: revert to 2018 edition (#847)
Fixes https://github.com/hyperium/tonic/issues/843
2021-12-07 09:49:07 +01:00
David PedersenandGitHub 65df87ad6c chore: Prepare tonic v0.5.2 (#738)
So as highlighted by
https://github.com/hyperium/tonic/issues/730#issuecomment-895635088 it
turns out the new `Interceptor` trait required changes to tonic-build as
well, which I forgot to publish yesterday. Didn't see it because it wasn't
clear from the commit message.

So this bumps tonic _and_ tonic-build to 0.5.2 so we can release both.
There are no code changes.
2021-08-10 15:35:36 +02:00
David PedersenandGitHub efe0865d26 chore: Prepare tonic v0.5.1 and tonic-health 0.4.1 (#737) 2021-08-09 17:20:36 +02:00
David PedersenandGitHub 4e578b5046 doc(tonic): add more interceptor examples (#736)
Some have asked how to use the new `Interceptor` trait to create named
interceptors. This updates the client example to show how to do that.
2021-08-09 16:42:15 +02:00
David PedersenandGitHub 99fdc98d41 chore: Prepare tonic-build v0.5.1 (#720) 2021-07-13 20:17:58 +02:00
David PedersenandGitHub 380d81dd86 fix(build): allow services to be named Service (#709)
Fixes https://github.com/hyperium/tonic/issues/676
2021-07-12 16:47:45 +02:00
David PedersenandGitHub 167e8cb5b2 fix(build): remove unnecessary Debug constraint for client streams (#719)
This was accidentally committed as part of
https://github.com/hyperium/tonic/pull/692.

Fixes https://github.com/hyperium/tonic/issues/718
2021-07-12 16:41:09 +02:00
David PedersenandGitHub 4b0ece6d28 chore: fix clippy lints (#707) 2021-07-09 18:23:55 +02:00
David PedersenandGitHub 5aa8ae1fec feat(examples): add grpc-web example (#710)
Creates a server using tonic-web and a client that uses a regular
`hyper::Client` and issues a regular HTTP/1.1 request.
2021-07-09 18:02:43 +02:00
David PedersenandGitHub acdb3273bb chore: update prost, and related crates, to 0.8 (#703)
* chore: update prost, and related crates, to 0.8

Updates prost, prost-derive, prost-build, and prost-types to 0.8.

* Update the last few places
2021-07-08 15:02:02 -04:00
David PedersenandGitHub 89df3380dd doc(tonic): mention tower-http's tracing middleware (#705)
Fixes https://github.com/hyperium/tonic/issues/654
2021-07-08 17:50:27 +02:00
David PedersenandGitHub 6711b80674 fix(tonic): don't remove reserved headers in interceptor (#701)
`InterceptedService` would previously use `tonic::Request::into_http`
which removes reserved headers. That mean inner middleware in the stack
wouldn't be able to see those headers, which could result in errors.

Fixes https://github.com/hyperium/tonic/issues/700
2021-07-08 10:30:46 -04:00
David PedersenandGitHub 0583cff80f feat(codec): compression support (#692)
* 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
2021-07-02 11:25:03 -04:00
2b60a00614 feat(transport): add connect timeout to Endpoint (#662)
Pulls in [hyper-timeout] which has a connector that can have a timeout
applied. I did consider vendoring hyper-timeout since its a fairly small
crate. I guess we can always do that later since its not exposed
publicly.

I would also like to add a test but I'm not sure about the best way of
testing this.

Fixes https://github.com/hyperium/tonic/issues/498

[hyper-timeout]: https://github.com/hjr3/hyper-timeout

Co-authored-by: Lucio Franco <[email protected]>
2021-07-01 10:23:22 -04:00
David PedersenandGitHub 12815d0a1d feat(tonic): expose setting for http2_adaptive_window (#657)
Fixes https://github.com/hyperium/tonic/issues/358
2021-06-21 12:42:52 -04:00
David PedersenandGitHub 3e95553c57 doc: mention Well Known Types in README (#661)
Fixes https://github.com/hyperium/tonic/issues/447
2021-06-02 16:59:09 +02:00
David PedersenandGitHub e82f0b0399 build: generate root crate paths correctly (#623)
We shouldn't append `proto_path` (`super` by default) if the path starts
with `crate::`.

Fixes https://github.com/hyperium/tonic/issues/548
2021-06-02 16:58:43 +02:00
David PedersenandGitHub 9cc14b79fb fix(codec): improve error message for invalid compression flag (#663)
* fix(codec): improve error message for invalid compression flag

Fixes https://github.com/hyperium/tonic/issues/492

* Update tonic/src/codec/decode.rs
2021-05-28 13:28:02 +02:00
David PedersenandGitHub e5e311853b feat(transport): provide generic access to connect info (#647) 2021-05-28 13:27:37 +02:00
David PedersenandGitHub 31a34681c7 fix(tonic): don't include error's cause in Display impl (#633)
At Embark we have a little helper function that converts a `&dyn
std::error::Error` into a `String` by walking the full chain of sources
(with `std::error::Error::source`) and joining them into a `String`.

We use that where we log errors to get as much information as possible
about whats causing an error. Works particularly well with anyhow's
`.context()` method.

However since `tonic::transport::Error` include its cause in their
`Display` impl we get the sources more than once.

As the cause can already be obtained through `std::error::Error::source`
no information should be lost by doing this.

Fixes https://github.com/hyperium/tonic/issues/632
2021-05-27 22:53:43 +02:00
David PedersenandGitHub 9478fac979 fix(build): fix with_interceptor not building on Rust 1.51 (#669)
Fixes https://github.com/hyperium/tonic/issues/666
2021-05-27 15:47:42 +02:00
David PedersenandGitHub 4d2667d1cb feat(tonic): make it easier to add tower middleware to servers (#651) 2021-05-19 09:19:58 +02:00
David PedersenandGitHub 4dda4cbcca feat(tonic): Use BoxBody from http-body crate (#622)
As of `http-body` 0.4.1 its has had a `BoxBody` type similar to
`tonic::body::BoxBody`. It also has `Empty` and `Body::map_{data,err}`.

That means all the custom body things we had in tonic can basically be
replaced with that.

Note that this is a breaking change so we should merge this next time we
decide to ship a breaking release.

The breaking changes are:

- `tonic::body::Body` has been removed. I think its fine for users to
depend directly on `http-body` if they need this trait.
- `tonic::body::BoxBody` is now just a type alias for
`http_body::combinators::BoxBody<Bytes, Status>`. So the methods it
previously had are gone. The replacements are
  - `tonic::body::Body::new` -> `http_body::Body::boxed`
  - `tonic::body::Body::map_from` -> `http_body::Body::map_data` and
  `http_body::Body::map_err` depending on which part you want to map.
  - `tonic::body::Body::empty` -> `http_body::Empty`

Additionally a `Sync` bound has been added to a few methods. I actually
don't think this is a breaking change because the old
`tonic::body::Body` trait had `Sync` as a supertrait meaning the `Sync`
requirement was already there.

Fixes https://github.com/hyperium/tonic/issues/557
2021-05-18 10:41:21 +02:00
David PedersenandGitHub 352b0f584b feat(tonic): add Request and Response extensions (#642)
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
2021-05-13 15:54:20 +02:00
David PedersenandGitHub 74ad0a998f fix(transport): remove needless BoxFuture (#644)
Should save some allocation. Didn't actually benchmark it.
2021-05-13 15:36:54 +02:00
David PedersenandGitHub 7862a2259d feat(tonic): pass trace_fn the request rather than just the headers (#634) 2021-05-12 18:24:09 +02:00
David PedersenandGitHub 2bf14e1d7d tonic: remove Code::__NonExhaustive (#625) 2021-05-12 18:23:12 +02:00
David PedersenandGitHub e97f518025 feat(metadata): remove manual Send + Sync impls for metadata types (#640) 2021-05-12 18:21:12 +02:00
David PedersenandGitHub 57509d321b fix(tonic): make Interceptor UnwindSafe (#641) 2021-05-12 18:20:33 +02:00
David PedersenandGitHub b0ec3ead34 feat(metadata): expose IterMut and ValuesMut (#639) 2021-05-12 18:20:03 +02:00
David PedersenandGitHub f33316d5b3 feat(tonic): implement From<Code> for i32
`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.
2021-05-12 16:42:23 +02:00
David PedersenandGitHub c39404d720 build: show all rustfmt output on errors (#621)
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
2021-05-08 16:11:03 +02:00
David PedersenandGitHub 8cfa44110c doc(tonic): mention tonic-reflection in README (#635)
Seems we forgot this one.
2021-05-08 16:09:44 +02:00
David PedersenandGitHub 4a917a32f0 fix(examples): Fix tower examples (#624)
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
2021-05-07 09:45:35 +02:00
David PedersenandGitHub 7f1af64527 chore: Prepare tonic 0.4.3 (#617)
* chore: Prepare tonic `0.4.3`

* Small typo fix
2021-04-29 16:57:28 +02:00
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
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
David PedersenandGitHub 5bc1aa9371 Mention rust-analyzer.cargo.loadOutDirsFromCheck setting in README (#561)
Fixes https://github.com/hyperium/tonic/issues/512
2021-04-14 09:08:08 +02:00
David PedersenandGitHub 7889c7ff97 Prepare 0.4.1 release (#580) 2021-03-16 17:39:57 +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