Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tonic example #72

Merged
merged 5 commits into from
Mar 21, 2021
Merged

Tonic example #72

merged 5 commits into from
Mar 21, 2021

Conversation

davidpdrsn
Copy link
Member

Fixes #63

@davidpdrsn davidpdrsn added the T-docs Topic: documentation label Feb 26, 2021
@davidpdrsn davidpdrsn added this to the 0.1.0 milestone Feb 26, 2021
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a few comments inline.

examples/tonic-key-value-store/src/main.rs Outdated Show resolved Hide resolved
examples/tonic-key-value-store/src/main.rs Outdated Show resolved Hide resolved
examples/tonic-key-value-store/src/main.rs Show resolved Hide resolved
>;

// Build a client with a few middlewares applied and connect to the server
async fn make_client(addr: SocketAddr) -> Result<Client, tonic::transport::Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet you could use impl Trait for the return type here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this

async fn make_client(
    addr: SocketAddr,
) -> Result<
    KeyValueStoreClient<
        impl Service<
                hyper::Request<BoxBody>,
                Response = hyper::Response<impl HttpBody<Error = impl Into<BoxError>>>,
                Error = impl Into<BoxError>,
            > + Clone
            + Send
            + Sync
            + 'static,
    >,
    tonic::transport::Error,
> {

The Clone + Send + Sync + 'static bound isn't strictly necessary for this example but I figure it might be nice to include for users copying this code.

@davidpdrsn davidpdrsn merged commit e84cc6f into master Mar 21, 2021
@davidpdrsn davidpdrsn deleted the tonic-example branch March 21, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example: gRPC API built with tonic
2 participants