kitejs
说明
kitejs 提供统一访问服务的 client,支持 Http、RPC(thrift) 协议,提供多种编解码方式(正在支持)。
kitejs 集成寻址、支持负载均衡策略
使用
首先进行安装
npm install kitejs --save
使用方法
const kite = require('kitejs');
var client = new kite.Client(
new kite.Config(
{
'host': '127.0.0.1',
'port': 8080,
'protocol': 'HTTP'
}
)
);
client.request(function (err, data) {
if (err) throw err;
console.log(data);
});
var client = new kite.Client(
new kite.Config(
{
'host': '127.0.0.1',
'port': 8080,
'protocol': 'THRIFT'
}
)
);
client
.loadService(__dirname + '/thrift/gen-nodejs/Calculator.js')
.request(function (err, cal, conn) {
if (err) throw err;
cal.ping(function (err, response) {
console.log('ping()');
});
cal.add(1, 1, function (err, response) {
console.log(response);
});
});
接口