Giter Club home page Giter Club logo

node-avro-serializer's Introduction

Node Avro Serializer Build Status

A small library providing serialization and deserialization routines for Apache avro binary encoding

Installation

npm install avro-serializer --save

Usage

var Serializer = require('avro-serializer');

var s = new Serializer({
    "type": "record",
    "name": "testRecord",
    "namespace": "com.test",
    "fields": [
        {"name": "name",    "type": "string"},
        {"name": "surname", "type": "string"},
        {"name": "title",   "type": "string"},
        {"name": "age",     "type": "long"}
    ]
});

var record = {
    name: "John",
    surname: "Smith",
    title: "User",
    age: 28
};

var buffer = s.serialize(record);
console.log(buffer.toString('hex'));

var newRecord = s.deserialize(buffer);
console.log(newRecord);

Tests

npm test

node-avro-serializer's People

Contributors

foxel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-avro-serializer's Issues

Fails hard on Schemas with Unions

Given the following schema:

{
  "namespace": "com.gilt.gumshoe.v1",
  "type": "record",
  "name": "GumshoeEvent",
  "fields": [
    {"name": "uuid", "type": "string"},

    {"name": "eventName", "type": "string"},
    {"name": "eventData", "type": ["null", "string"], "default": null},

    {"name": "gumshoe", "type": ["null", "string"], "default": null, "doc": "The version of the CDN/gumshoe.js script, for debugging purposes. "},

    {"name": "sessionUuid", "type": "string"},

    {"name": "timestamp", "type": "long"},
    {"name": "timezoneOffset", "type": "long"},

    {"name": "giltData", "type":
      {"type": "record",
       "name": "GiltData",
       "namespace": "com.gilt.gumshoe.v1.GumshoeEvent.GiltData",
       "fields": [
          {"name": "abTests", "type": ["null", "string"], "default": null},
          {"name": "applicationName", "type": ["null", "string"], "default": null},
          {"name": "channel", "type": ["null", "string"], "default": null},
          {"name": "groups", "type": ["null", "string"], "default": null},
          {"name": "guid", "type": ["null", "string"], "default": null},
          {"name": "hasPurchased", "type": ["null", "boolean"], "default": null},
          {"name": "isBotRequest", "type": ["null", "boolean"], "default": null},
          {"name": "isLoyaltyUser", "type": ["null", "boolean"], "default": null},
          {"name": "loyaltyStatus", "type": ["null", "string"], "default": null},
          {"name": "mode", "type": ["null", "string"], "default": null},
          {"name": "pricer", "type": ["null", "string"], "default": null},
          {"name": "section", "type": ["null", "string"], "default": null},
          {"name": "store", "type": ["null", "string"], "default": null},
          {"name": "subsite", "type": ["null", "string"], "default": null},
          {"name": "timezone", "type": ["null", "string"], "default": null},
          {"name": "vendorUserId", "type": ["null", "string"], "default": null},

          {"name": "tracking_api", "type": [
              "null",
              {"type": "record",
               "name": "TrackingAPI",
               "namespace": "com.gilt.gumshoe.v1.GumshoeEvent.GiltData.TrackingAPI",
               "doc": "The version of the tracking_api.gumshoe module, for debugging purposes.",
               "fields": [
                  {"name": "gumshoe", "type": ["null", "string"], "default": null}              ]
              }
            ],
            "default": null
          }
        ]
      }
    },

    {"name": "pageData", "type":
      {
        "type": "record",
        "name": "PageData",
        "namespace": "com.gilt.gumshoe.v1.GumshoeEvent.PageData",
        "fields": [
          {"name": "characterSet", "type": "string"},
          {"name": "colorDepth", "type": "string"},
          {"name": "cookie", "type": ["null", "string"], "default": null},
          {"name": "googleClickId", "type": "string"},
          {"name": "hash", "type": "string"},
          {"name": "host", "type": "string"},
          {"name": "hostName", "type": "string"},
          {"name": "ipAddress", "type": "string"},
          {"name": "javaEnabled", "type": "boolean"},
          {"name": "language", "type": "string"},
          {"name": "loginKey", "type": "string"},
          {"name": "origin", "type": "string"},
          {"name": "path", "type": "string"},
          {"name": "platform", "type": "string"},
          {"name": "plugins", "type": ["null", "string"], "default": null},
          {"name": "port", "type": "int"},
          {"name": "promotionKey", "type": "string"},
          {"name": "protocol", "type": "string"},
          {"name": "queryString", "type": "string"},
          {"name": "referer", "type": "string"},
          {"name": "screenAvailHeight", "type": "int"},
          {"name": "screenAvailWidth", "type": "int"},
          {"name": "screenHeight", "type": "int"},
          {"name": "screenOrientationAngle", "type": "int"},
          {"name": "screenOrientationType", "type": "string"},
          {"name": "screenPixelDepth", "type": "string"},
          {"name": "screenResolution", "type": "string"},
          {"name": "screenWidth", "type": "int"},
          {"name": "title", "type": "string"},
          {"name": "url", "type": "string"},
          {"name": "userAgent", "type": "string"},
          {"name": "utmCampaign", "type": "string"},
          {"name": "utmContent", "type": "string"},
          {"name": "utmMedium", "type": "string"},
          {"name": "utmSource", "type": "string"},
          {"name": "utmTerm", "type": "string"},
          {"name": "viewportHeight", "type": "int"},
          {"name": "viewportResolution", "type": "string"},
          {"name": "viewportWidth", "type": "int"}
        ]
      }
    }
  ]
}

There are a litany of errors using the example in the README. node-avro-io doesn't appear to support unions, etc. node-avro-io2 claims to, may be worth considering using that module.

Installation problem

Can not install with npm install avro-serializer --save getting
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror git://github.com/thecsyco/node-avro-io.git /root/.npm/_git-remotes/git-github-com-thecsyco-node-avro-io-git-1aa6f1d3: Initialized empty Git repository in /root/.npm/_git-remotes/git-github-com-thecsyco-node-avro-io-git-1aa6f1d3/

and many more.

Still maintained ? bug in pre-req library

Hi,

I have found a bug in the underlying node-avro-io library - but am using it via your package. I also see you are actually using a fork of the main node-avro-io package... - I would like to get one of them patched.

a) are you still maintaining this package
b) which library should I get patched... and then get you to bump the pre-req ?

Cant download/install

Hi, I'm getting the following when I try to get your library:

run:
npm install --save avro-serializer

callback:
npm WARN package.json [email protected] No README data
npm http GET https://registry.npmjs.org/avro-serializer
npm http 304 https://registry.npmjs.org/avro-serializer
npm ERR! git clone git://github.com/thecsyco/node-avro-io.git Cloning into bare repository '/home/romina/.npm/_git-remotes/git-github-com-thecsyco-node-avro-io-git-1aa6f1d3'...
npm ERR! git clone git://github.com/thecsyco/node-avro-io.git fatal: unable to connect to github.com:
npm ERR! git clone git://github.com/thecsyco/node-avro-io.git github.com[0: 192.30.252.130]: errno=Connection refused
npm ERR! Error: Command failed: Cloning into bare repository '/home/romina/.npm/_git-remotes/git-github-com-thecsyco-node-avro-io-git-1aa6f1d3'...
npm ERR! fatal: unable to connect to github.com:
npm ERR! github.com[0: 192.30.252.130]: errno=Connection refused
npm ERR!
npm ERR!
npm ERR! at ChildProcess.exithandler (child_process.js:637:15)
npm ERR! at ChildProcess.EventEmitter.emit (events.js:98:17)
npm ERR! at maybeClose (child_process.js:743:16)
npm ERR! at Process.ChildProcess._handle.onexit (child_process.js:810:5)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Linux 3.13.0-53-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "--save" "avro-serializer"
npm ERR! cwd /home/romina/workspace/cpp-web/node-server
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! code 128
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/romina/workspace/cpp-web/node-server/npm-debug.log
npm ERR! not ok code 0

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.