Commit Graph
54 Commits
Author SHA1 Message Date
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
Adam JacobandLucio Franco e034288c37 feat(build): Add extern_path config support (#223)
Adds support for prost-build's "extern_path" feature. This allows you to
reference another prost-generated protobuf, including any traits that
may have been defined for it, from another crate or location.
2020-01-10 15:31:10 -05:00
Lucio FrancoandGitHub 61a770dedf chore: Prepare 0.1.0-beta.1 release (#200)
* chore: Prepare `0.1.0-beta.1` release

* Update changelog

* Fix tower paths
2019-12-19 18:44:25 -05:00
Juan AlvarezandLucio Franco 3a5c66d5f2 fix(build): snake_case service names (#190) 2019-12-14 15:08:28 -05:00
Lucio FrancoandGitHub 97d5363e2b fix(build): Remove async ready (#185)
* fix(build): Remove async ready

* fix build
2019-12-13 18:19:23 -05:00
Lucio FrancoandGitHub 0847b67c4e fix(build): Allow creating multiple services in the same package (#173)
BREAKING CHANGE: Build will now generate each service client and server into their own modules.
2019-12-11 16:22:03 -05:00
Lucio FrancoandGitHub 3387ef900f Upgrade to tokio 0.2 (#163) 2019-12-06 00:09:46 -05:00
Lucio FrancoandGitHub 5fe21f3b24 chore: Prepare alpha.6 release (#130) 2019-11-10 17:40:51 +01:00
James SteeleandLucio Franco b02b4b238b fix(build): Prevent duplicated client/server generated code (#121)
* 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
2019-11-09 15:45:22 +00:00
Lucio FrancoandGitHub 3a39b1e7c8 chore: Prepare alpha.5 release (#108)
Signed-off-by: Lucio Franco <[email protected]>
2019-10-31 14:26:35 -04:00
Lucio FrancoandGitHub 5c2f4dba32 feat(transport): Change channel connect to be async (#107)
This makes it so you can check if the initial connection
is established. Before this we used reconnect which would
lazily attempt to connect. So if you were trying to connect
to a non existant Server you wouldn't find out until after
you attempted your first RPC. This simplifies everything
by allowing you connect before creating the RPC client.

BREAKING CHANGE: `Endpoint::channel` was removed in favor of
an async `Endpoint::connect`.
2019-10-31 14:09:40 -04:00
Lucio FrancoandGitHub 3ce61d9860 fix(codec): Enforce encoders/decoders are Sync (#84)
Closes #81
2019-10-30 15:00:31 -04:00
Lucio FrancoandGitHub 5b4f4689a2 feat(transport): Add service multiplexing/routing (#99)
* feat(transport): Add service multiplexing/routing

This change introduces a new "router" built on top of
`transport::Server` that allows one to run multiple
gRPC services on the same socket.

```rust
Server::builder()
    .add_service(greeter)
    .add_service(echo)
    .serve(addr)
    .await?;
```

There is also a new `multiplex` example showcasing
server side service multiplexing and client side
service multiplexing.

BREAKING CHANGES: `Server::serve` is now crate private
and all services must be added via `Server::add_service`.
Codegen also returns just a `Service` now instead of a
`MakeService` pair.

Closes #29

Signed-off-by: Lucio Franco [email protected]
2019-10-29 16:32:04 -04:00
Lucio FrancoandGitHub a17049f1f7 fix(codec): Remove custom content-type (#104)
This removes custom content-types in favor of
just using `application/grpc`. There is some
confusion around the specification but most
grpc implementations ignore the `+` and
anything after.
2019-10-29 16:12:41 -04:00
Juan AlvarezandLucio Franco 4bb087b5ff feat: Add IntoRequest and IntoStreamingRequest traits (#66) 2019-10-29 16:09:08 -04:00
Daniel PrilikandLucio Franco eea3c0f99a fix(build): Fix missing argument in generate_connect (#95) 2019-10-23 17:46:40 -04:00
Lucio FrancoandGitHub 77fc74038f chore: Prepare alpha.4 release (#91)
* chore: Prepare alpha.4 release

* Update changelog
2019-10-23 15:09:49 -04:00
Lucio FrancoandGitHub 1dbde95d84 fix(build): Fix service and rpc name conflict (#92)
Closes #89
2019-10-23 15:01:04 -04:00
Juan AlvarezandLucio Franco 7eda823c9c fix(client): Use Stream instead of TrySteam for client calls (#61) 2019-10-10 11:39:35 -04:00
Lucio FrancoandGitHub 8cddf8a12c chore: Prepare 0.1.0-alpha.3 release (#65) 2019-10-09 17:27:15 -04:00
Adam JacobandLucio Franco 06ff619944 feat(build): Expose prost-build type_attributes and field_attribu… (#60)
* chore: Add tags to .gitignore

When generating ctags/universal-ctags, a 'tags' file is generated. This
commit adds any generted 'tags' file to .gitignore.

* feat(build): Expose type_attribute and field_attribute

This commit exposes the `type_attribute` and `field_attribute`
configuration settings from Prost. These are useful to tweak/extend the
generated types.

For example:

```
tonic_build::configure()
    .out_dir(tmp)
    .format(false)
    .type_attribute(".", "#[derive(Serialize, Deserialize)]")
    .type_attribute(".", "#[serde(rename_all = \"camelCase\")]")
    .field_attribute("in", "#[serde(rename = \"in\")]")
    .compile(&["tests/protos/wellknown.proto"], &["tests/protos"])
    .unwrap();
```

Would add the serde `Serialize` and `Deserialize` traits, while renaming
all the fields to camelCase, and having serde keep fields named `in`
named `in`, rather than Prost's `in_`, to every type generated by Prost.
2019-10-08 18:11:42 -04:00
Lucio FrancoandGitHub 4628ff0258 chore: Prepare 0.1.0-alpha.2 release (#58)
Signed-off-by: Lucio Franco <[email protected]>
2019-10-07 22:01:59 -04:00
Lucio FrancoandGitHub 01e72d9a95 chore(build): Fix wrong output type used in replace (#50) 2019-10-05 14:18:13 -04:00
Lucio FrancoandGitHub 4e1fcece15 fix(codegen): Use wellknown types from prost-types (#49)
This change introduces the ability to let prost-build
provide the fully qualifed type path for types that
start with `google.protobuf`.
2019-10-05 13:16:09 -04:00
Lucio FrancoandGitHub 4559613c37 feat(codgen): Add default implementations for the generated serve… (#27)
* Rename servce -> server

* Add default impl for server trait
2019-10-02 16:01:44 -04:00
Lucio FrancoandGitHub 2670b349f9 fix(codegen): Fix Empty protobuf type and add unimplemented (#26)
* Add license attribute to tonic-build

* fix(codegen): Fix Empty protobuf type and add unimplemented

* Remove syn full feature
2019-10-01 23:46:54 -04:00
Lucio FrancoandGitHub a282b6682d chore(release): Prepare 0.1.0-alpha.1 release (#24) 2019-10-01 22:13:52 -04:00
Lucio FrancoandGitHub 8f80d0f6d1 chore(docs): Update tonic-build docs (#22) 2019-10-01 19:34:45 -04:00
Lucio Franco a35ef96a03 Add docs to transport and refactor some api's 2019-09-29 17:04:42 -04:00
Lucio Franco 1d9e3daa07 Remove generated doc comment test 2019-09-29 10:39:57 -04:00
John DonethandLucio Franco 8becd257bc More documentation generation (#12)
* generate rustdoc comments from .proto file comments

* move imports to top of file

* more docs gen

* trait docs

* more docs

* use singular doc gen fn here

* remove pesky space
2019-09-26 19:41:51 -04:00
Lucio Franco d2355ed83c fmt 2019-09-25 20:54:13 -04:00
John DonethandLucio Franco 36d0b1cb04 Generate rustdocs from .proto file comments (#10)
* generate rustdoc comments from .proto file comments

* move imports to top of file
2019-09-25 20:51:12 -04:00
John DonethandLucio Franco 646796f248 Add some doc examples (#9)
* doc examples for tonic::Streaming

* from http doc

* more docs

* use same export pattern

* interceptor doc WIP

* remove unfinished doc examples

* recommended changes

* remove unnecessary prost refs
2019-09-25 11:36:23 -04:00
Lucio Franco a37640c282 Fix doctest 2019-09-24 16:09:26 -04:00
Lucio Franco 1e579d1bd4 Fix rustfmt in tonic-build 2019-09-24 15:41:09 -04:00
Lucio Franco 72a0ffbbab Merge branch 'master' of github.com:LucioFranco/tonic 2019-09-23 21:00:41 -04:00
alceandLucio Franco 3dbb48f9f3 Delay determining out_dir (#3) 2019-09-23 20:59:16 -04:00
Lucio Franco bc500963b1 Merge branch 'master' of github.com:LucioFranco/tonic 2019-09-23 17:09:25 -04:00
John DonethandLucio Franco eb0c0c286b Improve tonic-build configuration (#2) 2019-09-23 09:32:44 -04:00
Lucio Franco cccc008366 todo clean up 2019-09-22 12:45:19 -05:00
Lucio Franco 782da6f0e5 implement last interop test 2019-09-21 16:02:10 -06:00
Lucio Franco 922e480cec Add easy connect method in codegen 2019-09-21 14:21:28 -06:00
Lucio Franco 5ded741eb6 Clean up docs 2019-09-21 11:20:30 -06:00
Lucio Franco cd9133a41c Doc hide codegen inner service 2019-09-21 11:13:18 -06:00
Lucio Franco 62f0285ff0 implemented server cusotm metadata 2019-09-21 10:23:31 -06:00
Lucio Franco da279a957d server codegen unimplemented 2019-09-20 15:39:03 -06:00
Lucio Franco f74bba6858 Add server interop tests 2019-09-06 21:40:59 -04:00
Lucio Franco cc8a7bfcbf make rustfmt optional 2019-09-06 18:25:27 -04:00