Skip to content

Minimal example of defining a gRPC proto API in Elixir and calling it in the interactive shell

Notifications You must be signed in to change notification settings

kvakvs/grpc_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GrpcDemo

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

Try it yourself

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}}

Installation

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.

About

Minimal example of defining a gRPC proto API in Elixir and calling it in the interactive shell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published