@sazze/thrift
v1.1.0
Published
A thrift client/server library
Downloads
2
Readme
@sazze/thrift
Helper library for the thrift
nodejs module.
Exampes
These examples expect that your generated thrift code is available in a nodejs module named <thrift_service_module>
Socket Client:
var thrift = require('@sazze/thrift');
var thriftService = require('<thrift_service_module>').Service;
var service = new thriftService.Client();
var options = {
host: 'localhost',
port: 9090,
};
var client = thrift.Client(options);
client.call(service.action, [], function (data) {
//success
}, function (err) {
// error
});
HTTP Client:
var thrift = require('@sazze/thrift');
var thriftService = require('<thrift_service_module>').Service;
var service = new thriftService.Client();
var options = {
type: 'http',
host: 'localhost',
port: 9090,
path: '/foo'
};
var client = thrift.Client(options);
clilent.call(service.action, [], function (data) {
//success
}, function (err) {
// error
});
Options
type
: [optional] 'http' or 'socket' (default: 'socket')host
: hostname or ip address of the serverport
: port the server is listening onpath
: the path where the server is listening (required whentype
= 'http')service
: the thrift service object (from thrift generated code)transport
: [optional] the thrift transport to use (default:thrift.TBufferedTransport
from thethrift
module)protocol
: [optional] the thrift protocol to use (default:thrift.TBinaryProtocol
from thethrift
module)