繁花如伊
需要用工具生成代码后调用,生成方法参见apache thrift 的get started部分然后引用生成的代码到工程,调用示例:var Calculator = require('../gen-nodejs/Calculator');var ttypes = require('../gen-nodejs/tutorial_types');var wrapper = require('co-thrift');var thrift = require('thrift');var connection = thrift.createConnection('localhost', 9090, { transport: thrift.TBufferedTransport(), protocol: thrift.TBinaryProtocol()});connection.on('error', function(err) { console.log(err);});var client = thrift.createClient(wrapper(Calculator.Client), connection);module.exports.add = function* (a, b) { yield client.add(a, b);};module.exports.ping = function* () { yield client.ping();};module.exports.establish = function *establish (name) { yield client.establishStream(name, '', 9090);}gen-nodejs 为生成的代码