Commit Graph
67 Commits
Author SHA1 Message Date
James NugentandGitHub 6dbe88d445 fix(build): Implement Debug for client struct
Fixes #298.
2020-03-30 17:06:31 -05:00
Lucio FrancoandGitHub 3cba9f5f6f chore: Fix feature flags and build docs (#311)
Signed-off-by: Lucio Franco <[email protected]>
2020-03-30 12:02:10 -04:00
Lucio FrancoandGitHub 2e082f8b3e chore(build): Refactor codegen traits (#302)
Signed-off-by: Lucio Franco <[email protected]>
2020-03-29 12:57:11 -04:00
Coenen BenjaminandGitHub 5758b758b2 fix(build): Server service uses generic body bound (#306)
Signed-off-by: Benjamin Coenen <[email protected]>
2020-03-28 12:52:10 -04:00
Juan AlvarezandGitHub e2c2be2f08 fix(build): Remove debug println! (#287) 2020-03-27 10:58:10 -04:00
James NugentandGitHub 224280dfff fix(build): Allow non_camel_case_types on codegen structs
This commit adjusts the code generation for the internal structs in the
implementation of Service<http::Request<HyperBody>> for *Server<T> in
order to annotate internal structs whose names are derived from gRPC
method names with `[allow(non_camel_case_types)]`. This supresses
compiler warnings about type names when compiling generated code. The
struct names are not exposed externally, so this has no impact on types
seen by library consumers.

Fixes #295.
2020-03-19 14:18:34 -05:00
Lucio FrancoandGitHub 7dfa2a277b fix(build): Ignore non .rs files with rustfmt (#284)
Fixes #283
2020-03-05 15:21:02 -05:00
Gyusun YeomandGitHub f65cda1ea0 feat(build): Decouple codgen from prost (#170) 2020-03-01 13:52:31 -05:00
Danny HuaandGitHub 1b3d107206 fix(build): Don't replace extern_paths (#261)
* don't replace extern_path'd paths

tonic-build will replace all paths except for google well known types
with one rooted at the super module. For paths that have already been
replaced with a fully qualified path via the extern_path config option,
(e.g. "::uuid::Uuid"), this results in an invalid path
(e.g. "super::::uuid::Uuid"), and a build failure. These paths should
also be excluded when prefixing relative modules with super.

* add doc in tonic-build clarifying extern_path

extern_path expects fully qualified proto and rust paths

* add test cast case for extern path fix

add a test that extern path does indeed result in service types using
the specified type from an external crate. we test this by creating a
service type that has a proto from a different crate, and asserting that
it does indeed impl a trait from that crate

* add license/publish to extern_path test crates
2020-02-18 09:56:32 -05:00
Lucio FrancoandGitHub 66ac4c4049 chore: Prepare 0.1.1 release (#246)
* chore: Prepare 0.1.1 release

* add missing pr
2020-01-20 11:53:45 -05:00
Spencer JudgeandLucio Franco 5fc6762435 fix(build): Typo with client mod docstring (#237) 2020-01-14 13:25:17 -05:00
Lucio FrancoandGitHub f4ecf47428 chore: Prepare 0.1.0 release (#234) 2020-01-14 09:36:19 -05:00
Juan AlvarezandLucio Franco 6ee2ed9b4f chore: rename ServiceName -> NamedService (#233)
BREAKING CHANGE: Rename `ServiceName` to `NamedService`.
2020-01-13 21:41:24 -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
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