0.1.17 • Published 9 years ago

node-thrift-protocol v0.1.17

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

node-thrift-protocol

An implementation of thrift-protocol with node.

Demo

let Thrift = require('node-thrift-protocol');

/* Server */

let server = Thrift.createServer(thrift => {
  thrift.on('data', message => {
    let { name, id, type } = message;
    thrift.write({
      name,
      id,
      type: 'REPLY',
      fields: [
        { id: 0, type: 'BOOL', value: true }
      ]
    });
  });
}).listen(8101);


/* Client */

let thrift = Thrift.connect({
  port: 8101,
  host: '127.0.0.1'
});

thrift.write({
  name: 'ping',
  type: 'CALL',
  id: 1
});

thrift.on('data', message => {
  let { id, name, type, fields } = message;
  fields.forEach(item => {
    let { id, type, value } = item;
  });
});

Usage

class Thrift extends stream.Duplex { ... }

This class is used to crate a thrift or local server.

Thrift.createServer(options);

Creates a new server. The connectionListener argument is automatically set as a listener for the 'connection' event.

options is an object as net.createServer in net module.

returns socket.

Thrift.connect(options, callback);

Opens the connection for a given socket.

options is an object as net.connect in net module.

return thrift.

new Thrift(socket);

Construct a new thrift object with a socket.

Protocol

thrift-protocol.txt

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago