Giter Site home page Giter Site logo

avro-protobuf's Introduction

avro-protobuf

Go

A schema and value conversion module and CLI tools in Go, like avro-protobuf.

It bundles protobuf <-> avro schema conversions, record value conversions, SerDe and protoc plugin.

Supported conversions

schema

  • protobuf descriptors -> Avro schema
    • supported
  • Avro schema -> protobuf descriptors
    • not yet

value

  • protobuf value -> Avro bytes
    • partially
  • Avro bytes -> protobuf value
    • not yet
  • protobuf bytes -> Avro value
    • not yet
  • Avro value -> protobuf bytes
    • partially

Usage

protobuf value <-> Avro bytes

    msg := &your_proto_message{}

    serDe, err := serde.NewSerDe(msg)
    if err != nil {
        t.Error(err)
    }

    bin, err = serDe.Serialize(msg)
    if err != nil {
        t.Error(err)
    }
    // Got avro bytes!
    
    msg2 := &your_proto_message{}
    err = serDe.Deserialize(bin, msg2)
    if err != nil {
        t.Error(err)
    }
    // Got protobuf struct value!

protobuf bytes <-> Avro value

  • TODO

protoc-gen-avro

It's a subproject of the avro-protobuf. It's a protoc plugin read .proto files and generate .avsc files. You can get a binary of the plugin at the release page of this GitHub repo, or go get

$ go get -u github.com/syucream/avro-protobuf/tree/master/cmd/protoc-gen-avro

It works as a protoc plugin, like:

$ cat proto/com/syucream/example/simple.proto
// https://developers.google.com/protocol-buffers/docs/proto3#simple

syntax = "proto3";

message SearchRequest {
    string query = 1;
    int32 page_number = 2;
    int32 result_per_page = 3;
 
$ protoc --plugin=./protoc-gen-avro --avro_out=./gen proto/com/syucream/example/simple.proto

$ cat gen/SearchRequest.avsc
{
  "fields": [
    {
      "default": "",
      "name": "query",
      "type": "string"
    },
    {
      "default": 0,
      "name": "page_number",
      "type": "int"
    },
    {
      "default": 0,
      "name": "result_per_page",
      "type": "int"
    }
  ],
  "name": "SearchRequest",
  "namespace": "google.protobuf",
  "type": "record"
}

references

avro-protobuf's People

Contributors

syucream avatar

Watchers

 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.