Java IDL for gRPC / protobuf (Protocl Buffers)

2019-04-17 05:57发布

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条回答
劫难
2楼-- · 2019-04-17 06:28

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)

查看更多
登录 后发表回答