Giter Club home page Giter Club logo

eprotoc's Introduction

eprotoc

Erlang proto file parser and code generator.

goals

The project has several goals:

  1. Avoid record syntax
  • Protocol buffer messages are expected to be used by potentially many modules
  • Records aren't easily shared across modules
  1. Preserve the flexibility of protocol buffers
  • Protocol buffers are meant to be backwards compatibile and the underlying data structure should not break this
  • We are using keylists for now but this may change as benchmarks are performed (orddicts are also an option).
  1. Avoid header files
  • Header files make it harder to reason about code and break encapsulation intrinsic to protocol buffers
  • Prefer instead module-based organization of messages and enums

In addition, the project introduces no new dependencies (everything is raw erlang).

usage

To build the project, you need rebar in your $PATH, after which you can just run make or rebar compile.

The project ships with a simple convenience script for generating code from .proto files. To do so run:

eprotoc /path/to/file.proto /path/to/src/dir

This will generate a number of modules to the path you specify. For example:

package Foo;

message Bar {
    required uint32 zap = 1;
}

will output the module foo__bar.erl with the functions

fun g_zap/1,
fun s_zap/2,
fun encode/1,
fun decode/1

The first two functions are a getter and setter for the zap field and the last two functions are an encoder and decoder for a bar message list. To create a new message of type Bar, we would just use an empty list since lists are the internal structure of the message:

NewBar = foo__bar:s_zap([], 100),
foo__bar:encode(NewBar).

This creates an iolist representing a Bar message with zap set to 100 that can then be sent over the wire.

See the test folder for examples of enum usage, the repeated field, nested messages, imported messages, and more.

known caveats

  • missing tests on a number of data types and cases of more extreme nesting

roadmap

  1. Add more tests

eprotoc's People

Contributors

johnfoconnor avatar tyler-eon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.