Message Protocol
The current message protocol is Protobuf.
You can find the file defining the spec in the root of the project messages.proto
Generating the files from .proto
When using Protobuf the common thing to do is use generators that take you .proto
files and generated the code in your language of choice.
Since we have 2 distinct langauages (Elixir, C#) below you will find the sections for each one
Elixir
For Elixir we use the library protobuf
Requirements:
- Protobuf compiler (
protoc
), you can check the releases for a pre-built binary or in macOS dobrew install protobuf
protoc-gen-elixir
plugin forprotoc
. Install withmix escript.install hex protobuf
and make sure to include in yourPATH
, if you are using asdf runasdf reshim
Generating code:
After much trial and error, we distilled the code generation into a simple command you can use from the root of the project
make gen-server-protobuf
This will generate 2 files
messages.pb.ex
, which is the module specifying the structs (and other things) for our protobuf messagesproto_transform.ex
, this module is referenced bymessages.pb.ex
in thetransform_module/0
callback. This module handles the transformation from our data types (structs, maps, etc) into the generated structs of the protobuf messages (and viceversa)
CSharp
For C# we use the library protobuf-net
Requirements:
- Protobuf compiler (
protoc
), you can check the releases for a pre-built binary or in macOS dobrew install protobuf
- .NET6 runtime needed by
protogen
3.2.12 - protogen tool to generate the code, similar to
protoc
Generating code:
After much trial and error, we distilled the code generation into a simple command you can use from the root of the project
make gen-client-protobuf