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 0.1.1 produces code which does not compile. #249

Closed
tkaitchuck opened this issue Jan 22, 2020 · 4 comments
Closed

Tonic 0.1.1 produces code which does not compile. #249

tkaitchuck opened this issue Jan 22, 2020 · 4 comments

Comments

@tkaitchuck
Copy link

tkaitchuck commented Jan 22, 2020

Bug Report

When building with tonic 0.1.1 many compile errors of the following from appear:

error[E0277]: the trait bound `controller::ServerRequest: prost::message::Message` is not satisfied
##[error]   --> /home/runner/work/pravega-client-rust/pravega-client-rust/target/debug/build/pravega-controller-client-3df4ddb1cd436cfb/out/io.pravega.controller.stream.api.grpc.v1.rs:529:24
    |
529 |             self.inner.unary(request.into_request(), path, codec).await
    |                        ^^^^^ the trait `prost::message::Message` is not implemented for `controller::ServerRequest`
    |
    = note: required because of the requirements on the impl of `tonic::codec::Codec` for `tonic::codec::prost::ProstCodec<controller::ServerRequest, _>`

Version

0.1.1
Noticeably this does not happen with tonic 0.1.0-beta.1

Platform

Linux workdesktop 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Crates

An unreleased crate. However the proto that is causing the problem is here:
https://github.com/pravega/pravega/blob/master/shared/controller-api/src/main/proto/Controller.proto

Description

The code to pull in the proto is:

#[allow(non_camel_case_types)]
mod controller {
    tonic::include_proto!("io.pravega.controller.stream.api.grpc.v1");
    // this is the rs file name generated after compiling the proto file, located inside the target folder.
}

Running this with tonic 0.1.0-beta.1 there were no issues, with 0.1.1 it does not compile.

@alce
Copy link
Collaborator

alce commented Jan 23, 2020

Hi @tkaitchuck, make sure you have the correct version of prost. For tonic 0.1.1 it should be 0.6. Also, if you just upgraded tonic, also upgrade tonic-build and generate your protos again.

@tkaitchuck
Copy link
Author

This fixed the problem. Feel free to close.
Should prost be a public dependency?

@alce
Copy link
Collaborator

alce commented Jan 24, 2020

Yes. This is because generated structs derive prost::Message, and it needs to be available directly on your project.

/// EchoRequest is the request for echo.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EchoRequest {
    #[prost(string, tag = "1")]
    pub message: std::string::String,
} 

@LucioFranco
Copy link
Member

Yup, this is due to prost's macros requiring it at the root level nothing we can really do about this unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants