Skip to content

surgeventures/elixir-rpc-proto-gen-helpers

Repository files navigation

RPCProtoGenHelpers

This library defines a buf custom plugin.

This plugin reads in a bunch of proto files, and for the RPC services generates some helpers: behaviour modules and "impl" modules to make calling and testing gRPC methods easier.

This repo is not intended to be used directly, but rather includes an escript. This can be used as part of a shell script:

which protoc-gen-elixir-rpc || PATH="~/.mix/escripts:$PATH" && mix escript.install --force github surgeventures/elixir-rpc-proto-gen-helpers

Then you can use the plugin for buf generate. An example buf config file might be:

version: v2
plugins:
  - local: protoc-gen-elixir
    strategy: all
    out: ./lib/generated
    opt: plugins=grpc
  - local: protoc-gen-elixir-rpc
    strategy: all
    out: ./lib/generated
    opt: plugins=grpc

Note that protoc-gen-elixir is a separate plugin.

To visualise the metadata structure that is parsed, see buf.example.json.

To generate such a file run buf build --output export.json.

## Testing

This plugin is tested with integration tests which call buf generate.

If you want to run tests, make sure you have buf installed at version 1.40 or greater.

Running tests assumes that certain executables are in your PATH:

PATH="~/.mix/escripts:$PATH" && \
mix escript.install --force hex protobuf 0.7.1 && \
mix escript.build && mix escript.install --force protoc-gen-elixir-rpc

Every time you change the CLI code, you must run mix escript.build && mix escript.install --force protoc-gen-elixir-rpc.

Installation

If available in Hex, the package can be installed by adding rpc_proto_gen_helpers to your list of dependencies in mix.exs:

def deps do
  [
    {:rpc_proto_gen_helpers, "~> 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/rpc_proto_gen_helpers.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published