All Projects → elixir-grpc → Grpc

elixir-grpc / Grpc

Licence: apache-2.0
An Elixir implementation of gRPC

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Grpc

Rpc Thunderdome
A comparison between Proteus RPC and other commonly used RPC frameworks
Stars: ✭ 22 (-97.44%)
Mutual labels:  grpc, rpc, protobuf
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-82.87%)
Mutual labels:  grpc, rpc, protobuf
Grpcc
A gRPC cli interface for easy testing against gRPC servers
Stars: ✭ 1,078 (+25.64%)
Mutual labels:  grpc, protobuf, http2
Go Grpc Examples
This repo contains examples and implementations of different types of GRPC services and APIs using Golang.
Stars: ✭ 180 (-79.02%)
Mutual labels:  grpc, rpc, protobuf
Yarpc Go
A message passing platform for Go
Stars: ✭ 285 (-66.78%)
Mutual labels:  grpc, rpc, protobuf
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+295.34%)
Mutual labels:  grpc, rpc, http2
Grpc Rust
Rust implementation of gRPC
Stars: ✭ 1,139 (+32.75%)
Mutual labels:  grpc, protobuf, http2
tsrpc
A TypeScript RPC framework, with runtime type checking and serialization, support both HTTP and WebSocket. It is very suitable for website / APP / games, and absolutely comfortable to full-stack TypeScript developers.
Stars: ✭ 866 (+0.93%)
Mutual labels:  protobuf, grpc, rpc
Brpc Java
Java implementation for Baidu RPC, multi-protocol & high performance RPC.
Stars: ✭ 647 (-24.59%)
Mutual labels:  grpc, rpc, protobuf
Flatbuffers
FlatBuffers: Memory Efficient Serialization Library
Stars: ✭ 17,180 (+1902.33%)
Mutual labels:  grpc, rpc, protobuf
Servicetalk
A networking framework that evolves with your application
Stars: ✭ 656 (-23.54%)
Mutual labels:  grpc, rpc, http2
Srpc
RPC based on C++ Workflow
Stars: ✭ 521 (-39.28%)
Mutual labels:  rpc, protobuf
Prototool
Your Swiss Army Knife for Protocol Buffers
Stars: ✭ 4,932 (+474.83%)
Mutual labels:  grpc, protobuf
Libra Sdk Go
Go SDK for the Libra cryptocurrency
Stars: ✭ 23 (-97.32%)
Mutual labels:  grpc, rpc
Swell
Swell: API development tool that enables developers to test endpoints served over streaming technologies including Server-Sent Events (SSE), WebSockets, HTTP2, GraphQL, and gRPC.
Stars: ✭ 517 (-39.74%)
Mutual labels:  grpc, http2
Multi V2ray
v2ray/xray多用户管理部署程序
Stars: ✭ 5,382 (+527.27%)
Mutual labels:  http2, grpc
Lnd Grpc Client
A python grpc client/async client for LND ⚡⚡⚡
Stars: ✭ 26 (-96.97%)
Mutual labels:  grpc, rpc
Roadrunner
🤯 High-performance PHP application server, load-balancer and process manager written in Golang
Stars: ✭ 6,122 (+613.52%)
Mutual labels:  rpc, http2
Proteus
Generate .proto files from Go source code.
Stars: ✭ 593 (-30.89%)
Mutual labels:  grpc, protobuf
Grpcurl
Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
Stars: ✭ 6,149 (+616.67%)
Mutual labels:  grpc, protobuf

gRPC Elixir

Hex.pm Travis Status GitHub actions Status Inline docs

An Elixir implementation of gRPC.

WARNING: Be careful to use it in production! Test and benchmark in advance.

NOTICE: Erlang/OTP needs >= 20.3.2

NOTICE: grpc_gun

Now {:gun, "~> 2.0.0", hex: :grpc_gun} is used in mix.exs because grpc depnds on Gun 2.0, but its stable version is not released. So I published a 2.0 version on hex with a different name. So if you have other dependencies who depends on Gun, you need to use override: {:gun, "~> 2.0.0", hex: :grpc_gun, override: true}. Let's wait for this issue https://github.com/ninenines/gun/issues/229.

Installation

The package can be installed as:

def deps do
  [
    {:grpc, github: "elixir-grpc/grpc"},
    # 2.9.0 fixes some important bugs, so it's better to use ~> 2.9.0
    {:cowlib, "~> 2.9.0", override: true}
  ]
end

Usage

  1. Generate Elixir code from proto file as protobuf-elixir shows(especially the gRPC Support section).
  2. Implement the server side code like below and remember to return the expected message types.
defmodule Helloworld.Greeter.Server do
  use GRPC.Server, service: Helloworld.Greeter.Service

  @spec say_hello(Helloworld.HelloRequest.t, GRPC.Server.Stream.t) :: Helloworld.HelloReply.t
  def say_hello(request, _stream) do
    Helloworld.HelloReply.new(message: "Hello #{request.name}")
  end
end
  1. Start the server

You can start the gRPC server as a supervised process. First, add GRPC.Server.Supervisor to your supervision tree.

# Define your endpoint
defmodule Helloworld.Endpoint do
  use GRPC.Endpoint

  intercept GRPC.Logger.Server
  run Helloworld.Greeter.Server
end

# In the start function of your Application
defmodule HelloworldApp do
  use Application
  def start(_type, _args) do
    children = [
      # ...
      supervisor(GRPC.Server.Supervisor, [{Helloworld.Endpoint, 50051}])
    ]

    opts = [strategy: :one_for_one, name: YourApp]
    Supervisor.start_link(children, opts)
  end
end

Then start it when starting your application:

# config.exs
config :grpc, start_server: true

# test.exs
config :grpc, start_server: false

$ iex -S mix

or run grpc.server using a mix task

$ mix grpc.server
  1. Call rpc:
iex> {:ok, channel} = GRPC.Stub.connect("localhost:50051")
iex> request = Helloworld.HelloRequest.new(name: "grpc-elixir")
iex> {:ok, reply} = channel |> Helloworld.Greeter.Stub.say_hello(request)

# With interceptors
iex> {:ok, channel} = GRPC.Stub.connect("localhost:50051", interceptors: [GRPC.Logger.Client])
...

Check examples and interop(Interoperability Test) for some examples.

TODO

  • [x] Unary RPC
  • [x] Server streaming RPC
  • [x] Client streaming RPC
  • [x] Bidirectional streaming RPC
  • [x] Helloworld and RouteGuide examples
  • [x] Doc and more tests
  • [x] Authentication with TLS
  • [x] Improve code generation from protos (protobuf-elixir #8)
  • [x] Timeout for unary calls
  • [x] Errors handling
  • [x] Benchmarking
  • [x] Logging
  • [x] Interceptors(See GRPC.Endpoint)
  • [x] Connection Backoff
  • [x] Data compression
  • [x] Support other encoding(other than protobuf)

Benchmark

  1. Simple benchmark by using ghz

  2. Benchmark followed by official spec

Sponsors

This project is being sponsored by Tubi. Thank you!

Contributing

You contributions are welcome!

Please open issues if you have questions, problems and ideas. You can create pull requests directly if you want to fix little bugs, add small features and so on. But you'd better use issues first if you want to add a big feature or change a lot of code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].