Commit Graph
53 Commits
Author SHA1 Message Date
Anthony GreenandGitHub dee2ab52ff feat(transport): add unix socket support in server (#861) 2022-02-14 15:00:58 -05:00
tottotoandGitHub 366d888a4b chore: Fix clippy lints (#881) 2022-01-12 16:32:40 -05:00
JimmyandGitHub 16321c279f docs: fix typo in the streaming example. (#871) 2021-12-25 00:03:20 +01:00
Cezar MatheandGitHub 8508f369c2 fix(examples): Fix autoreload example (#798) (#818) 2021-11-01 18:29:44 -04:00
Lucio FrancoandGitHub 23c1392fb7 fix(tonic): Remove Sync requirement for streams (#804) 2021-10-24 21:48:05 -04:00
Lucio FrancoandGitHub bbcacd0625 chore: Fix routeguide example warning (#807) 2021-10-22 11:17:04 -04:00
Lucio FrancoandGitHub 4604042934 Add streaming example w/ client disconnect (#782) 2021-10-07 17:04:26 -04: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
Yotam OfekandGitHub 8c8f4d1251 feat(tonic): add Interceptor trait (#713)
* Expose `Interceptor` trait.

* Revert changes to public API surface.

* Rename types, add deprecated alias for old names.
2021-07-27 11:11:51 -04: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
Lucio FrancoandGitHub 2346d99f6e example: Add mocked io example (#677)
* example: Add mocked io example

* fix mock example

* Remove uniex bound for mock impl
2021-07-08 10:45:04 -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
David PedersenandGitHub e5e311853b feat(transport): provide generic access to connect info (#647) 2021-05-28 13:27:37 +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 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 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
Juan J. Jimenez-AncaandGitHub 4b26e78109 add docs for health checks (#599) 2021-05-01 17:30:54 +02:00
Junichi SugiuraandGitHub db22c3568d Fix ListFeaturesStream return type on RouteGuide Tutorial (#586) 2021-04-04 21:06:33 +02:00
c54f24721c feat: Implement gRPC Reflection Service (#340)
Co-authored-by: Samani G. Gikandi <[email protected]>
2021-02-16 11:07:51 -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
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
Juan AlvarezandGitHub 0c69c378fd chore: clippy lints (#467)
* chore: clippy lints
2020-09-29 14:38:49 -05:00
Lucio FrancoandGitHub 9ea4a64a6c examples: Add tower-client example (#466) 2020-09-29 11:16:07 -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 73938e1e0a chore: Fix typo in uds example (#417)
Closes #350
2020-07-27 15:38:47 -04:00
Harry BarberandGitHub 2b997b0c5f feat(transport): Add optional service methods (#275) 2020-07-10 12:39:52 -04:00
034c850254 examples: update to tracing 0.1.16, use #[instrument] (#354)
* examples: update to `tracing` 0.1.14, use `#[instrument]`

Now that `tracing-attributes`'s `#[instrument]` macro plays nicely with
`async-trait`, we can update the tracing example to use `instrument`.
This lets us simplify the events emitted in the example.

Signed-off-by: Eliza Weisman <[email protected]>

* feat(transport): Dynamic load balancing (#341)

* Fix typo (#356)

Co-authored-by: Dawid Nowak <[email protected]>
Co-authored-by: Paulo Duarte <[email protected]>
2020-07-10 11:59:18 -04:00
Lucio FrancoandGitHub c9b3c7f11c Fix hyper_warp example warnings (#390) 2020-07-10 11:28:13 -04:00
Johan AnderssonandGitHub 3b9d6a6262 fix(transport): Propagate errors in tls_config instead of unwrap/panic (#385)
* Propagate errors in tls_config instead of unwrap

Ran into `tls_connector` failing and causing our app to panic and shutdown as it seems there wasn't any way to avoid panicking in `tls_config`.

So after talking to @LucioFranco briefly `tls_config` now returns a `Result` instead and propagates errors to the caller, where they can be handled.

* Fix compile warning when tls feature is disabled
2020-07-06 09:18:10 -04:00
Kaleb ElwertandGitHub 80e90e3b5d Add tower server example (#375)
Note that this also adds `impl From<Status> for http::Response<BoxBody>`
in order to make writing middleware which can return an error much
easier.
2020-06-22 12:04:02 -04:00
Taiki EndoandGitHub 5bda615632 fix: Remove uses of pin_project::project attribute (#367)
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
2020-06-09 13:09:35 -04:00
Dawid NowakandGitHub 85ae0a4733 feat(transport): Dynamic load balancing (#341) 2020-05-15 15:03:28 -04:00
thisKaiandGitHub f6ecaff0de chore(example): Autoreloading server example (#316)
* Create an example of an autoreloading server

* Document the autoreloading server example

* Format autoreloading server example

* Add note about cargo-watch in the examples readme
2020-04-09 17:55:53 -04:00
Spencer JudgeandGitHub b7860cc734 chore: Update blocking example drop order (#313) 2020-04-01 14:01:38 -04:00
James NugentandGitHub da92dbf8aa feat(health): Add tonic-health server impl
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.md

Fixes #135.
2020-03-30 09:33:02 -05:00
9e7d35a2d3 chore: Add blocknig server example (#277)
Co-authored-by: Lucio Franco <[email protected]>
2020-03-06 11:30:10 -05:00
Lucio FrancoandGitHub e2bff8f13e chore(docs): Add warp + tonic example (#268)
Signed-off-by: Lucio Franco <[email protected]>
2020-02-16 15:13:22 -05:00
Lucio FrancoandGitHub b49ad9bb47 chore(docs): Add hyper example (#267)
Signed-off-by: Lucio Franco <[email protected]>
2020-02-16 12:46:55 -05:00
DizansandGitHub 34865a9fb5 chore(docs): Remove unecessary pinning (#263) 2020-02-13 11:34:34 -05:00
Lucio FrancoandGitHub eba7ec7b32 feat: Add gRPC interceptors (#232)
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`.
2020-01-13 21:26:08 -05:00
Juan AlvarezandLucio Franco a41f55ab9d fix(build): Remove default impl for Server traits (#229)
BREAKING CHANGE: remove default implementations for server traits.
2020-01-13 09:42:14 -05:00
Lucio FrancoandGitHub af807c3ccd feat(transport): Add server side peer cert support (#228)
* feat(transport): Add server side peer cert support
2020-01-11 14:17:19 -08:00
Johan AnderssonandLucio Franco 3be8bc1668 Run CI checks & tests on Windows and Mac (#206)
* Run CI checks & tests on Windows and Mac

* Fix uds windows compile

Co-authored-by: Lucio Franco <[email protected]>
2020-01-11 14:16:54 -08:00
Thomas MayandLucio Franco 59d008db7e chore(docs): Fix examples link (#202)
* url is just examples, not tonic-examples

* Change root directory from tonic-examples to examples.  Matches current directory structure.
2019-12-20 22:39:39 -05:00
Juan AlvarezandLucio Franco 4e5c6c8f23 chore(example): update guides to 0.1-beta.1 (#198)
* update routeguide

* update helloworld

* depend on tonic beta.1

* Apply suggestions from code review

Co-Authored-By: Lucio Franco <[email protected]>

Co-authored-by: Lucio Franco <[email protected]>
2019-12-19 18:23:25 -05:00
Juan AlvarezandLucio Franco 3a5c66d5f2 fix(build): snake_case service names (#190) 2019-12-14 15:08:28 -05:00
Lucio FrancoandGitHub 82facb6283 chore: Apply clippy (#189) 2019-12-13 23:55:49 -05:00
Lucio FrancoandGitHub 502491a590 fix(transport): Remove with_rustls for tls config (#188) 2019-12-13 20:31:22 -05:00