All Projects → synrc → rpc

synrc / rpc

Licence: ISC License
☎️ RPC: Type Driven Parser Generator

Programming Languages

erlang
1774 projects
elixir
2628 projects

Labels

Projects that are alternatives of or similar to rpc

grpc-jwt-spring-boot-starter
Spring boot starter for gRPC framework with JWT authorization
Stars: ✭ 24 (+50%)
Mutual labels:  protobuf
protocol
The schemas for the Harmony protocol
Stars: ✭ 16 (+0%)
Mutual labels:  protobuf
pbkit
protobuf toolkit for typescript and others
Stars: ✭ 173 (+981.25%)
Mutual labels:  protobuf
twjitm-core
采用Netty信息加载实现长连接实时通讯系统,客户端可以值任何场景,支持实时http通讯、webSocket通讯、tcp协议通讯、和udp协议通讯、广播协议等 通过http协议,rpc协议。 采用自定义网络数据包结构, 实现自定义网络栈。
Stars: ✭ 98 (+512.5%)
Mutual labels:  protobuf
deprecated-pokemongo-game-master
⚠️ DEPRECATED - LOOK README ⚠️ This repository is collection of the decoded GAME_MASTER-protobuf files
Stars: ✭ 38 (+137.5%)
Mutual labels:  protobuf
minipb
Mini Protobuf {,de}serializer
Stars: ✭ 34 (+112.5%)
Mutual labels:  protobuf
tilegrinder
♻️ A node.js GIS helper library for easy alteration of Vector Tiles in an MBTiles container
Stars: ✭ 64 (+300%)
Mutual labels:  protobuf
ocaml-grpc-envoy
Using OCaml + gRPC via Envoy
Stars: ✭ 41 (+156.25%)
Mutual labels:  protobuf
protostuff-example
Experimenting protostuff
Stars: ✭ 13 (-18.75%)
Mutual labels:  protobuf
grpc-chat
Simple Chat Server/Client implemented with gRPC
Stars: ✭ 107 (+568.75%)
Mutual labels:  protobuf
sisyphus
Sisyphus is the way how we provide backend services.
Stars: ✭ 59 (+268.75%)
Mutual labels:  protobuf
gosproto
基于云风的sproto二进制标准上的描述文件及代码生成工具
Stars: ✭ 52 (+225%)
Mutual labels:  protobuf
agentgo
Hi! Agentgo is a tool for making remote command executions from server to client with golang, protocol buffers (protobuf) and grpc.
Stars: ✭ 15 (-6.25%)
Mutual labels:  protobuf
CSGO-Item-Floats-From-Inspect-Links
cuz bored as fuck, how to get the item floats from inspect links aka the market float "method"
Stars: ✭ 53 (+231.25%)
Mutual labels:  protobuf
graphql-binary
GraphQL binary protocol for smaller network traffic and parsing performance
Stars: ✭ 41 (+156.25%)
Mutual labels:  protobuf
grphp
PHP gRPC Framework
Stars: ✭ 19 (+18.75%)
Mutual labels:  protobuf
modern-api-management
A modern approach to manage APIs effectively using Protobuf
Stars: ✭ 36 (+125%)
Mutual labels:  protobuf
javascript-serialization-benchmark
Comparison and benchmark of JavaScript serialization libraries (Protocol Buffer, Avro, BSON, etc.)
Stars: ✭ 54 (+237.5%)
Mutual labels:  protobuf
protobuf-d
Protocol Buffers Compiler Plugin and Support Library for D
Stars: ✭ 32 (+100%)
Mutual labels:  protobuf
gosmparse
Processing OpenStreetMap PBF files at speed with Go
Stars: ✭ 55 (+243.75%)
Mutual labels:  protobuf

RPC: ERLANG API SDK Generators

Actions Status Build Status Hex pm

The main idea is to have unified code of any possible generators for all languages from HRL Type Specification.

Supported Generators

  • Erlang validation according to Type Spec (BERT)
  • JavaScript (BERT)
  • Swift (BERT)
  • Google Protobuf Specification (PROTOBUF)

Intro

As you may know, Erlang has its own binary encoding BERT inside its virtual machine, called BEAM. For enterprise RPC usually, you use protobuf or MessagePack or Thrift or ASN.1 binary parser generators. However, as you may know Erlang is not so fast in any tasks except moving binaries between sockets. So we at Synrc usually use native Erlang BERT encoding on all clients with zero encoding/decoding on server side.

The encoders/decoders could be of two types: strict (with checking the model for particular type signature with Sums and Products) and general which encode/decode anything that can be translated into correct encoding. For example, JavaScript encoder/decode generator presented in this repo is just like that (it doesn't check types and constants, given in Erlang HRL files). However, Swift version has the ability to check encoded/decoded term to comply the Erlang Type Specification.

Samples

First, you can choose the language which is not presented in this repo and try to implement your own BERT enc/dec generator for this language using Swift (Type Spec precise) and JavaScript (open relay) generator as examples.

The aim of this contest is to create encoders/decoders for each language and make bridges to other protocol descriptive formats like Can'n'Proto or protobuf!

Erlang HRL

-record(error, { code=[] :: [] | binary() }).
-record(ok, { code=[] :: [] | binary() }).
-record(io, { code=[] :: [] | #ok{} | #error{},
              data=[] :: [] | <<>> 
                | { atom(), binary() | integer() } }).

Swift Model

class Err {
    var code: AnyObject?
}
class Ok {
    var code: AnyObject?
}
class Io {
    var code: AnyObject?
    var data: AnyObject?
}

Swift Spec

Chain(types: [
     Model(value:Tuple(name: "io", body: [
          Model(value:Chain(types: [
               Model(value: Tuple(name:"ok", body: [
                    Model(value:Atom())])),
               Model(value: Tuple(name:"error", body: [
                    Model(value:Atom())]))])),
          Model(value:Tuple(name:"", body:[
               Model(value:Atom()),
               Model(value:Chain(types: [
                    Model(value:Binary()),
                    Model(value:Number())]))]))])) ])

JavaScript

function check() {
    var res = true;
    //@TODO: MORE TEST DATA
    testData = [
        1,
        [1, 2, 3],
        "string",
        {tup: 'io', code: 'login', data: {tup: '$', 0: 'Auth', 1: 12}},
        {tup: 'io', code: 'login', data: {tup: 'Auth'}},
        {tup: 'io', code: 'login', data: {tup: '$', 0: 'doe', 1: 12}},
        {tup: 'Roster', userlist: [{tup: 'Contact'}], status: 'get'},
        {tup: 'p2p', from: 'john', to: 'doe'},
        {tup: 'Profile', accounts: [1], status: 'maxim'}
    ];
    testData.forEach(function (o) {
        var o = JSON.stringify(o);
        var d = JSON.stringify(
                decode(dec(enc(encode(o)).buffer)))
                 .replace(/\\/g, '');

        if (JSON.stringify(o) != JSON.stringify(
             decode(dec(enc(encode(o)).buffer)))) {
            console.log("Original: " + o + " <=> Decode: " 
                + d + " %c [Error]", "color: red");
            res = false;
        } else {
            console.log("Data: " + o + " %c [OK]", "color: green");
        }
    });

    return res;
}

Protobuf Sample

Erlang BERT/HRL (source):

-type authType()   :: google_api | facebook_api | mobile |
                      email | voice | resend | verify | 
                      push | logout | get | delete | clear.

-type authStatus() :: invalid_version | mismatch_user_data |
                      number_not_allowed | session_not_found |
                      attempts_expired | invalid_sms_code |
                      invalid_jwt_code | permission_denied |
                      invalid_data.

-record('Feature',  { id    = [] :: [] | binary(),
                      key   = [] :: [] | binary(),
                      value = [] :: [] | binary(),
                      group = [] :: [] | binary()}).

-record('Auth',     { client_id   = [] :: [] | binary(),
                      dev_key     = [] :: [] | binary(),
                      user_id     = [] :: [] | binary(),
                      phone       = [] :: [] | binary(),
                      token       = [] :: [] | binary(),
                      type        = email :: authStatus(),
                      sms_code    = [] :: [] | binary(),
                      attempts    = [] :: [] | integer(),
                      services    = [] :: list(atom()),
                      settings    = [] :: list(#'Feature'{}),
                      push        = [] :: [] | binary(),
                      os          = [] :: [] | ios | android | web,
                      created     = [] :: [] | integer(),
                      last_online = [] :: [] | integer() }).

Proto V3 (target):

enum osEnum {
    ios = 0;
    android = 1;
    web = 2;
}

enum authStatus {
    invalid_version = 0;
    mismatch_user_data = 1;
    number_not_allowed = 2;
    session_not_found = 3;
    attempts_expired = 4;
    invalid_sms_code = 5;
    invalid_jwt_code = 6;
    permission_denied = 7;
    invalid_data = 8;
}

message Feature {
    string id = 1;
    string key = 2;
    string value = 3;
    string group = 4;
}

message Auth {
    string client_id = 1;
    string dev_key = 2;
    string user_id = 3;
    string phone = 4;
    string token = 5;
    authStatus type = 6;
    string sms_code = 7;
    int64 attempts = 8;
    repeated google.protobuf.Any services = 9;
    repeated Feature settings = 10;
    string push = 11;
    osEnum os = 12;
    int64 created = 13;
    int64 last_online = 14;
}

Run

$ mad com
==> "/Users/maxim/depot/synrc/bert"
Generated Protobuf Model: "priv/protobuf/authType.proto"
Generated Protobuf Model: "priv/protobuf/authStatus.proto"
Generated Protobuf Model: "priv/protobuf/Feature.proto"
Generated Protobuf Model: "priv/protobuf/Auth.proto"
Generated Protobuf Model: "priv/protobuf/AuthError.proto"
Compiling /src/bert_sample.erl
OK

Credits

  • Yuri Maslovsky — ERLANG
  • Maxim Sokhatsky — GOOGLE, JAVASCRIPT
  • Dmytro Boiko — ERLANG, JAVASCRIPT
  • Anton Makarov — SWIFT
  • Viacheslav Katsuba — JAVASCRIPT

Let's build true native Erlang zero-overhead encoders/decoders for all languages with you!

OM A HUM

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].