Closed freshtonic closed 2 years ago
Looking at GRPC.Message
it doesn't look like being Protobuf only since the message is encoded/decoded using the codec. I might be wrong though!
For codecs see for instance.
usage:
defmodule HelloServer do
use GRPC.Server,
service: Helloworld.Greeter.Service,
codecs: [GRPC.Codec.Erlpack]
def say_hello(req, _stream) do
Helloworld.HelloReply.new(message: "Hello, #{req.name}")
end
end
defmodule HelloStub do
use GRPC.Stub, service: Helloworld.Greeter.Service
end
{:ok, channel} = GRPC.Stub.connect("localhost:8080")
req = Helloworld.HelloRequest.new(name: "hello")
{:ok, reply} = channel |> HelloStub.say_hello(req, codec: GRPC.Codec.Erlpack)
You can implement your own by implementing the codec
behaviour.
Hope it helps!
Thanks @drowzy - that's great. I swear I looked at the project README and "support protocols other than Protobufs" was unchecked :)
Currently, it seems that only Protobuf is supported as a wire format.
How coupled is this library to Protobuf and is there a plan to support alternative wire formats?