blob: 61b933a759349b36bf1ebb8f87212d0a4aa72867 [file] [log] [blame]
Henrique Mendonca8d410de2012-10-22 18:35:30 +00001/**
2
3 This is a standalone deserialize/parse example if you just want to deserialize
4 thrift decoupled from cassandra server
5
6 1. acquire thrift template specification files from who ever built it (eg: EXAMPLE.thrift)
7
8 2. Install thrift on local machine (ie, via "brew install thrift")
9
10 3. generate thrift clients for nodejs using template specification files (#1)
11 thrift --gen js:node schema/EXAMPLE.thrift
12
13 This creates creates gen-node.js directory containing a new file, GENERATED.js
14
15 4. Inside GENERATED.js is a class you will want to instanciate. Find this class name and plug
16 it into the example code below (ie, "YOUR_CLASS_NAME")
17 */
18
19function parseThrift(thriftEncodedData, callback) {
20 var thrift = require('thrift');
21 var transport = new thrift.TFramedTransport(thriftEncodedData);
22 var protocol = new thrift.TBinaryProtocol(transport);
23
24 var clientClass = require('../gen-nodejs/GENERATED').YOUR_CLASS_NAME;
25 var client = new clientClass();
26 client.read(protocol);
27 callback(null, client);
28}