quick-protobuf icon indicating copy to clipboard operation
quick-protobuf copied to clipboard

Would it support service?

Open AndreMouche opened this issue 8 years ago • 4 comments
trafficstars

Would it support service one day, it seems not work for the following situation:

syntax = "proto3";
package grpc;

service HelloService {
  rpc SayHello (HelloRequest) returns (HelloResponse);
}

message HelloRequest {
  string greeting = 1;
}

message HelloResponse {
  string reply = 1;
}

AndreMouche avatar Nov 17 '17 02:11 AndreMouche

Indeed it is not supported for the moment and there is no short term plan to support it (support goes beyond simple protobuf serialization/deserialization).

On the other hand, I'd be happy to make any modification you think would be missing for another crate to implement it fully (i.e. providing some simple rust structs/traits). The code generation part should be relatively simple.

tafia avatar Nov 17 '17 05:11 tafia

just generating the traits would be very helpful!

aep avatar Apr 22 '18 20:04 aep

Prost has a config for plugging in an external service generator: https://docs.rs/prost-build/0.3.2/prost_build/struct.Config.html#method.service_generator

That seems like another solution.

nerdrew avatar Sep 15 '18 02:09 nerdrew

I am not a big fan to be honest, I believe it doesn't fit too well with rust.

I think i prefer a trait based approach, or even a sync and an async which would use Future (you can decide in config which one suits you the best)

pub trait HelloService {
    type Error;
    fn SayHello(_req: &HelloRequest) -> Result<HelloRespone, Self::Error>;
}

pub trait HelloServiceAsync {
    type Error;
    type Response: Future<Item = HelloResponse, Error = Self::Error>;
    fn SayHello(_req: &HelloRequest) -> Self::Response;
}

That being said, I am open to any solution at the moment because I don't plan on working on this right now.

tafia avatar Sep 15 '18 13:09 tafia