Code Monkey home page Code Monkey logo

thrift-bigint's Introduction

node-thrift

Thrift protocol implementation for nodejs. As of version 0.0.1, the basic protocol has been implemented. A Thrift compiler that will generate the .js files from a Thrift specification is being implemented as well, see the Thrift Compiler section below.

NOTE: you must use the framed thrift transport, TFramedTransport in most implementations, on the server side. Using a popular example, this is enabled by default in Cassandra 0.7 (but configuration must be changed in Cassandra 0.6.x and earlier).

Install

npm install thrift 

Thrift Compiler

A Thrift compiler is being built in a forked version of the upstream thrift library. You can check it out here: https://github.com/wadey/thrift

Once you build this patched version of Thrift, you can compile nodejs sources by running the following:

thrift --gen js:node thrift_file

Cassandra Client Example:

Here is a Cassandra example:

var thrift = require('thrift'),
    Cassandra = require('./gen-nodejs/Cassandra')
    ttypes = require('./gen-nodejs/cassandra_types');

var connection = thrift.createConnection("localhost", 9160),
    client = thrift.createClient(Cassandra, connection);

connection.on('error', function(err) {
  console.error(err);
});

client.get_slice("Keyspace", "key", new ttypes.ColumnParent({column_family: "ExampleCF"}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', finish: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
  if (err) {
    // handle err
  } else {
    // data == [ttypes.ColumnOrSuperColumn, ...]
  }
  connection.end();
});

Custom client and server example

An example based on the one shown on the Thrift front page is included in the examples folder.

thrift-bigint's People

Contributors

sandosh avatar

Stargazers

 avatar

Watchers

 avatar James Cloos 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.