Demonstrates concept of using gRPC client and server in an Elixir project. Demonstrates simplicity of setting up dependencies and the proto file.
Dependencies: Cowboy, Gun, Ranch, Cowlib
Building proto files yourself: see instructions at https://github.com/tony612/grpc-elixir
Create connection
{:ok, ch} = GRPC.Stub.connect("localhost:1111")
Create request and call the stub, it should connect the call to remote server
implementation in GrpcDemo.Server
.
req = GrpcDemo.GRPC.HelloRequest.new(i: true)
ch |> GrpcDemo.GRPC.Api.Stub.hello(req)
Result should be: {:ok, %GrpcDemo.GRPC.HelloResponse{i: true}}
If available in Hex, the package can be installed
by adding grpc_demo
to your list of dependencies in mix.exs
:
def deps do
[
{:grpc_demo, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/grpc_demo.