Skip to content

Commit

Permalink
THRIFT-2932: Node.js Thrift connection libraries throw Exceptions int…
Browse files Browse the repository at this point in the history
…o event emitter

Client: Nodejs
Patch: Tom Croucher and Andrew de Andrade

This commits a limited set of hunks from teh original patch.
  • Loading branch information
RandyAbernethy committed Feb 4, 2015
1 parent 281bdae commit a727007
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
8 changes: 2 additions & 6 deletions lib/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ Here is a Cassandra example:

Since JavaScript represents all numbers as doubles, int64 values cannot be accurately represented naturally. To solve this, int64 values in responses will be wrapped with Thirft.Int64 objects. The Int64 implementation used is [broofa/node-int64](https://github.com/broofa/node-int64).

## Libraries using node-thrift
## Client and server examples

* [yukim/node_cassandra](https://github.com/yukim/node_cassandra)

## Custom client and server example

An example based on the one shown on the Thrift front page is included in the examples/ folder.
Several example clients and servers are included in the thrift/lib/nodejs/examples folder and the cross language tutorial thrift/tutorial/nodejs folder.
10 changes: 6 additions & 4 deletions lib/nodejs/lib/thrift/http_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var util = require('util');
var http = require('http');
var https = require('https');
var EventEmitter = require("events").EventEmitter;
var EventEmitter = require('events').EventEmitter;
var thrift = require('./thrift');
var ttransport = require('./transport');
var tprotocol = require('./protocol');
Expand Down Expand Up @@ -93,8 +93,8 @@ var HttpConnection = exports.HttpConnection = function(host, port, options) {
this.nodeOptions[attrname] = this.options.nodeOptions[attrname];
}
/*jshint -W069 */
if (! this.nodeOptions.headers["Connection"]) {
this.nodeOptions.headers["Connection"] = "keep-alive";
if (! this.nodeOptions.headers['Connection']) {
this.nodeOptions.headers['Connection'] = 'keep-alive';
}
/*jshint +W069 */

Expand Down Expand Up @@ -132,7 +132,9 @@ var HttpConnection = exports.HttpConnection = function(host, port, options) {
var clientCallback = client._reqs[header.rseqid];
delete client._reqs[header.rseqid];
if (clientCallback) {
clientCallback(err, success);
process.nextTick(function() {
clientCallback(err, success);
});
}
};
/*jshint +W083 */
Expand Down
2 changes: 0 additions & 2 deletions lib/nodejs/test/thrift_test_driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ client.testDouble(7.012052175215044, function(err, response) {
assert.equal(7.012052175215044, response);
});

// TODO: add testBinary()

var out = new ttypes.Xtruct({
string_thing: 'Zero',
byte_thing: 1,
Expand Down

0 comments on commit a727007

Please sign in to comment.