2016-01-21 34 views
0

有什么用节俭上的NodeJS这两个包的区别是:
- thrift
- thrift-http
乍一看似乎thrift-http将需要使用thrift超过http,但我安装了thrift包,它确实有其中定义了一个createHttpConnection方法。下面是示例代码中,我写道:NodeJS:节俭vs thrift-http包 - 使用哪一个?

var thrift = require('thrift'); 
var myService = require('./gen-nodejs/MyService'); 
var transport = thrift.TBufferedTransport; 
var protocol = thrift.TBinaryProtocol; 
// connect to proxy on 127.0.0.1:8888 
var connection = thrift.createHttpConnection('127.0.0.1', 8888, { 
    transport : transport, 
    protocol : protocol, 
    path: 'http://localhost:5331/myhandler', 
}); 

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

// Create a client with the connection 
var client = thrift.createHttpClient(myService, connection); 
console.log('calling getTotalJobCount...'); 

client.getTotalJobCount(function(count) 
{ 
    console.log('total job count = ' + count); 
}); 

但是当我运行它,我得到这个:

total job count = NULL 

这并不如预期的服务回报无法在客户端回调出现NULL的整数。现在我无法找到链接,但昨天我在http读的地方,节俭只支持TJSONProtocol。现在是否正确?这就是我看到NULL的原因吗?我在哪里可以看到nodejs中节俭的源代码? This是搜索“thrift nodejs”时出现在Google中的第一个链接,它似乎代码完全过时。

回答

0

thrift包是由Apache Thrift项目组提供的包。

另一种是别人的包,不涉及任何形式的“官方”的来源。在对相关提交进行快速检查后,这些文件的版本似乎也是0.9.3,这是最新的正式版本。但是,我不能说所有这些文件是完全原创的,还是已经修改过。你必须自己验证(或者只是相信那个人)。