You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by he...@apache.org on 2013/06/09 23:07:29 UTC

[1/2] git commit: THRIFT-1659 Bring nodejs default transport in line with Java default transport

Updated Branches:
  refs/heads/master de07408e4 -> 6afe0535e


THRIFT-1659 Bring nodejs default transport in line with Java default transport


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/27db434f
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/27db434f
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/27db434f

Branch: refs/heads/master
Commit: 27db434fd93b8ebd4235f2e2cbbecb5b8be76ce4
Parents: de07408
Author: Henrique Mendonça <he...@apache.org>
Authored: Sun Jun 9 21:48:39 2013 +0200
Committer: Henrique Mendonça <he...@apache.org>
Committed: Sun Jun 9 22:20:25 2013 +0200

----------------------------------------------------------------------
 lib/nodejs/lib/thrift/connection.js | 54 +++++++++++++++-----------------
 lib/nodejs/lib/thrift/server.js     |  2 +-
 test/nodejs/Makefile.am             |  4 +--
 test/nodejs/client.js               |  2 +-
 4 files changed, 29 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/27db434f/lib/nodejs/lib/thrift/connection.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/lib/thrift/connection.js b/lib/nodejs/lib/thrift/connection.js
index 05c5a6c..a49d427 100644
--- a/lib/nodejs/lib/thrift/connection.js
+++ b/lib/nodejs/lib/thrift/connection.js
@@ -30,7 +30,7 @@ var Connection = exports.Connection = function(stream, options) {
 
   this.connection = stream;
   this.options = options || {};
-  this.transport = this.options.transport || ttransport.TFramedTransport;
+  this.transport = this.options.transport || ttransport.TBufferedTransport;
   this.protocol = this.options.protocol || tprotocol.TBinaryProtocol;
   this.offline_queue = [];
   this.connected = false;
@@ -135,43 +135,39 @@ exports.createClient = function(cls, connection) {
 
 var child_process = require('child_process');
 var StdIOConnection = exports.StdIOConnection = function(command, options) {
-	var command_parts = command.split(' ');
-	command = command_parts[0];
-	var args = command_parts.splice(1,command_parts.length -1);
-	var child = this.child = child_process.spawn(command,args);
+  var command_parts = command.split(' ');
+  command = command_parts[0];
+  var args = command_parts.splice(1,command_parts.length -1);
+  var child = this.child = child_process.spawn(command,args);
 
   var self = this;
   EventEmitter.call(this);
 
-	this._debug = options.debug || false;
+  this._debug = options.debug || false;
   this.connection = child.stdin;
   this.options = options || {};
-  this.transport = this.options.transport || ttransport.TFramedTransport;
+  this.transport = this.options.transport || ttransport.TBufferedTransport;
   this.protocol = this.options.protocol || tprotocol.TBinaryProtocol;
   this.offline_queue = [];
 
-	if(this._debug === true){
-
-  this.child.stderr.on('data',function(err){
-			console.log(err.toString(),'CHILD ERROR');
-
-		});
-
-	this.child.on('exit',function(code,signal){
-			console.log(code+':'+signal,'CHILD EXITED');
-
-		});
+  if(this._debug === true){
+    this.child.stderr.on('data',function(err){
+      console.log(err.toString(),'CHILD ERROR');
+    });
 
-	}
+    this.child.on('exit',function(code,signal){
+      console.log(code+':'+signal,'CHILD EXITED');
+    });
+  }
 
-	this.frameLeft = 0;
-	this.framePos = 0;
-	this.frame = null;
-	this.connected = true;
+  this.frameLeft = 0;
+  this.framePos = 0;
+  this.frame = null;
+  this.connected = true;
 
-	self.offline_queue.forEach(function(data) {
-			self.connection.write(data);
-	});
+  self.offline_queue.forEach(function(data) {
+      self.connection.write(data);
+  });
 
 
   this.connection.addListener("error", function(err) {
@@ -226,7 +222,7 @@ StdIOConnection.prototype.write = function(data) {
   this.connection.write(data);
 }
 exports.createStdIOConnection = function(command,options){
-	return new StdIOConnection(command,options);
+  return new StdIOConnection(command,options);
 
 };
 
@@ -236,8 +232,8 @@ exports.createStdIOClient = function(cls,connection) {
   }
 
   var client = new cls(new connection.transport(undefined, function(buf) {
-		connection.write(buf);
-	}), connection.protocol);
+    connection.write(buf);
+  }), connection.protocol);
 
   // TODO clean this up
   connection.client = client;

http://git-wip-us.apache.org/repos/asf/thrift/blob/27db434f/lib/nodejs/lib/thrift/server.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/lib/thrift/server.js b/lib/nodejs/lib/thrift/server.js
index a17419b..f219048 100644
--- a/lib/nodejs/lib/thrift/server.js
+++ b/lib/nodejs/lib/thrift/server.js
@@ -26,7 +26,7 @@ exports.createServer = function(cls, handler, options) {
     cls = cls.Processor;
   }
   var processor = new cls(handler);
-  var transport = (options && options.transport) ? options.transport : ttransport.TFramedTransport;
+  var transport = (options && options.transport) ? options.transport : ttransport.TBufferedTransport;
   var protocol = (options && options.protocol) ? options.protocol : TBinaryProtocol;
 
   return net.createServer(function(stream) {

http://git-wip-us.apache.org/repos/asf/thrift/blob/27db434f/test/nodejs/Makefile.am
----------------------------------------------------------------------
diff --git a/test/nodejs/Makefile.am b/test/nodejs/Makefile.am
index 2c0a18f..7668039 100755
--- a/test/nodejs/Makefile.am
+++ b/test/nodejs/Makefile.am
@@ -35,8 +35,8 @@ check: stubs
 clean-local:
 	$(RM) -r gen-nodejs
 
-server: stubs
+server:
 	NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node server.js
 
-client: stubs
+client:
 	NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node client.js

http://git-wip-us.apache.org/repos/asf/thrift/blob/27db434f/test/nodejs/client.js
----------------------------------------------------------------------
diff --git a/test/nodejs/client.js b/test/nodejs/client.js
index ea2cc38..269aab3 100644
--- a/test/nodejs/client.js
+++ b/test/nodejs/client.js
@@ -23,7 +23,7 @@ var assert = require('assert');
 var ThriftTest = require('./gen-nodejs/ThriftTest'),
     ttypes = require('./gen-nodejs/ThriftTest_types');
 
-//var connection = thrift.createConnection('localhost', 9090, { 'transport': ttransport.TBufferedTransport }),
+//var connection = thrift.createConnection('localhost', 9090, { 'transport': ttransport.TFramedTransport }),
 var connection = thrift.createConnection('localhost', 9090),
     client = thrift.createClient(ThriftTest, connection);
 


[2/2] git commit: THRIFT-1659 Bring nodejs default transport in line with Java default transport

Posted by he...@apache.org.
THRIFT-1659 Bring nodejs default transport in line with Java default transport


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/6afe0535
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/6afe0535
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/6afe0535

Branch: refs/heads/master
Commit: 6afe0535e1cd07bb799897dd2232db845d35662a
Parents: 27db434
Author: Henrique Mendonça <he...@apache.org>
Authored: Sun Jun 9 22:54:51 2013 +0200
Committer: Henrique Mendonça <he...@apache.org>
Committed: Sun Jun 9 22:54:51 2013 +0200

----------------------------------------------------------------------
 test/nodejs/Makefile.am | 2 +-
 test/nodejs/client.js   | 8 ++++----
 test/nodejs/server.js   | 3 +++
 3 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/6afe0535/test/nodejs/Makefile.am
----------------------------------------------------------------------
diff --git a/test/nodejs/Makefile.am b/test/nodejs/Makefile.am
index 7668039..f796b07 100755
--- a/test/nodejs/Makefile.am
+++ b/test/nodejs/Makefile.am
@@ -28,7 +28,7 @@ check: stubs
 	fi
 	@if which node &> /dev/null ; then \
 		echo "   Testing Client/Server"; \
-		timeout -s14 3 $(MAKE) server & \
+		timeout -s14 5 $(MAKE) server & \
 		sleep 1; $(MAKE) client; sleep 2; \
 	fi
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/6afe0535/test/nodejs/client.js
----------------------------------------------------------------------
diff --git a/test/nodejs/client.js b/test/nodejs/client.js
index 269aab3..d96400e 100644
--- a/test/nodejs/client.js
+++ b/test/nodejs/client.js
@@ -17,14 +17,14 @@
  * under the License.
  */
 var thrift = require('thrift');
-//var ttransport = require('transport');
+var ttransport = require('transport');
 var assert = require('assert');
 
 var ThriftTest = require('./gen-nodejs/ThriftTest'),
     ttypes = require('./gen-nodejs/ThriftTest_types');
 
-//var connection = thrift.createConnection('localhost', 9090, { 'transport': ttransport.TFramedTransport }),
-var connection = thrift.createConnection('localhost', 9090),
+var connection = thrift.createConnection('localhost', 9090, { 'transport': ttransport.TFramedTransport }),
+//var connection = thrift.createConnection('localhost', 9090),
     client = thrift.createClient(ThriftTest, connection);
 
 connection.on('error', function(err) {
@@ -255,7 +255,7 @@ client.testI32(-1, function(err, response) {
 setTimeout(function() {
   console.log("Server successfully tested!");
   connection.end();
-}, 200);
+}, 1500);
 
 // to make it also run on expresso
 exports.expressoTest = function() {};

http://git-wip-us.apache.org/repos/asf/thrift/blob/6afe0535/test/nodejs/server.js
----------------------------------------------------------------------
diff --git a/test/nodejs/server.js b/test/nodejs/server.js
index 06724e6..28eeeae 100644
--- a/test/nodejs/server.js
+++ b/test/nodejs/server.js
@@ -18,6 +18,7 @@
  */
 var thrift = require('thrift');
 var Thrift = thrift.Thrift;
+var ttransport = require('transport');
 
 var ThriftTest = require('./gen-nodejs/ThriftTest'),
     ttypes = require('./gen-nodejs/ThriftTest_types');
@@ -214,6 +215,8 @@ var server = thrift.createServer(ThriftTest, {
       console.log('Done sleeping for testOneway!');
     }, sleepFor*1000); //seconds
   }
+}, { //server options
+  'transport': ttransport.TFramedTransport
 });
 
 server.listen(9090);