THRIFT-2167 nodejs lib throws error if options argument isn't passed
authorhenrique <henrique@apache.org>
Mon, 9 Sep 2013 10:38:25 +0000 (12:38 +0200)
committerhenrique <henrique@apache.org>
Mon, 9 Sep 2013 10:38:25 +0000 (12:38 +0200)
Client: nodejs
Patch: Randy Abernethy and Red Daly

also add examples to test makefile

compiler/cpp/src/generate/t_js_generator.cc
lib/nodejs/lib/thrift/connection.js
test/nodejs/Makefile.am

index 565bb80..7c42c01 100644 (file)
@@ -1010,7 +1010,7 @@ void t_js_generator::generate_service_client(t_service* tservice) {
   // utils for multiplexed services
   if (gen_node_) {
     indent(f_service_) <<  js_namespace(tservice->get_program())<<service_name_ << "Client.prototype.seqid = function() { return this._seqid; }" << endl <<
-    js_namespace(tservice->get_program())<<service_name_ << "Client.prototype.new_seqid = function() { this._seqid += 1; }" << endl;
+    js_namespace(tservice->get_program())<<service_name_ << "Client.prototype.new_seqid = function() { return this._seqid += 1; }" << endl;
   }
   // Generate client method implementations
   vector<t_function*> functions = tservice->get_functions();
index 4581d81..8303b08 100644 (file)
@@ -35,20 +35,20 @@ var Connection = exports.Connection = function(stream, options) {
   this.offline_queue = [];
   this.connected = false;
 
-  this._debug = options.debug || false;
-  if (options.max_attempts
-     && !isNaN(options.max_attempts) && options.max_attempts > 0) {
-     this.max_attempts = +options.max_attempts;
+  this._debug = this.options.debug || false;
+  if (this.options.max_attempts
+     && !isNaN(this.options.max_attempts) && this.options.max_attempts > 0) {
+     this.max_attempts = +this.options.max_attempts;
   }
   this.retry_max_delay = null;
-  if (options.retry_max_delay !== undefined
-     && !isNaN(options.retry_max_delay) && options.retry_max_delay > 0) {
-     this.retry_max_delay = options.retry_max_delay;
+  if (this.options.retry_max_delay !== undefined
+     && !isNaN(this.options.retry_max_delay) && this.options.retry_max_delay > 0) {
+     this.retry_max_delay = this.options.retry_max_delay;
   }
   this.connect_timeout = false;
-  if (options.connect_timeout
-     && !isNaN(options.connect_timeout) && options.connect_timeout > 0) {
-     this.connect_timeout = +options.connect_timeout;
+  if (this.options.connect_timeout
+     && !isNaN(this.options.connect_timeout) && this.options.connect_timeout > 0) {
+     this.connect_timeout = +this.options.connect_timeout;
   }
   this.connection.addListener("connect", function() {
     self.connected = true;
index ab9a554..a8c10aa 100755 (executable)
@@ -30,12 +30,14 @@ check: stubs
                echo "   Testing Client/Server"; \
                timeout -s14 5 $(MAKE) server & \
                sleep 1; $(MAKE) client; sleep 2; \
-       fi
-
-       @if which node &> /dev/null ; then \
+               \
                echo "   Testing Multiplex Client/Server"; \
                sleep 4; timeout -s14 5 $(MAKE) mserver & \
                sleep 1; $(MAKE) mclient; sleep 2; \
+               \
+               echo "   Testing Client/Server examples"; \
+               sleep 4; timeout -s14 5 $(MAKE) -C ../../lib/nodejs/examples server & \
+               sleep 1; $(MAKE) -C ../../lib/nodejs/examples client; sleep 2; \
        fi
 
 clean-local: