0.2.0 • Published 8 years ago

co-thrift v0.2.0

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

co-thrift

Co wrapper for thrift clients.

The wrapper just searches the prototype for every method, which does not start with send_ or recv_ and replaces it with a version you can yield. This may not be save, but it works for my purpose.

WARNING: The client prototype gets changed. This could be a problem.

Installation

$ npm install co-thrift

Example

Just do as you normally do in thrift, but pass the Client object to the wrapper.

Line:

var client = thrift.createClient(wrapper(StreamingService.Client), connection);
// ...
yield client.establishStream(name, '', port);

Full Example:

var wrapper = require('co-thrift'),
    thrift = require('thrift')
    StreamingService = require('./StreamingService');

var transport = thrift.TFramedTransport;
var protocol = thrift.TBinaryProtocol;

var connection = thrift.createConnection('host', port, {
    transport: transport,
    protocol: protocol
});

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

var client = thrift.createClient(wrapper(StreamingService.Client), connection);

module.exports.establish = function *establish (name) {
    yield client.establishStream(name, '', port);
}

License

ISC

0.2.0

8 years ago

0.1.1

10 years ago

0.1.0

10 years ago