Java IDL for gRPC / protobuf (Protocl Buffers)

我是研究僧i 提交于 2019-12-06 17:09:22

问题


Is it possible to define Protocol Buffers using Java?

That is instead of

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

I would like to have

public interface Greeter {
    @Grpc
    HelloReply sayHello (HelloRequest req);

}

@GrpcMessage()
public class HelloReply{
    @GrpcField(1)
    string name;
} 

That is annotation like Hibernate/JPA over my POJO, instead of heaps of generated code.

I only could find Protocol Buffers Dynamic Schema https://github.com/os72/protobuf-dynamic


回答1:


Have a look at protostuff: https://github.com/protostuff/protostuff It supports what you want for protobuf (although not for grpc, perhaps it can be enhanced)



来源:https://stackoverflow.com/questions/40425211/java-idl-for-grpc-protobuf-protocl-buffers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!