You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ra...@apache.org on 2014/03/29 09:18:42 UTC

git commit: THRIFT-2398:Improve Node Server Library CLIENT: node Patch: Randy Abernethy

Repository: thrift
Updated Branches:
  refs/heads/master ea6076f17 -> a2e4e5659


THRIFT-2398:Improve Node Server Library
CLIENT: node
Patch: Randy Abernethy

Update node hello web example and line ending clean up.


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

Branch: refs/heads/master
Commit: a2e4e565983d247fbcf634a52ddb85cec872e96f
Parents: ea6076f
Author: ra <ra...@apache.org>
Authored: Sat Mar 29 01:14:48 2014 -0700
Committer: ra <ra...@apache.org>
Committed: Sat Mar 29 01:14:48 2014 -0700

----------------------------------------------------------------------
 lib/js/test/server_http.js              |  98 ++++---
 lib/js/test/server_https.js             |  96 ++++---
 lib/nodejs/README.md                    |   2 +-
 lib/nodejs/examples/hello.html          |  12 +-
 lib/nodejs/examples/hello.js            |  20 +-
 lib/nodejs/test/test_handler.js         | 388 +++++++++++++--------------
 lib/nodejs/test/test_handler_promise.js | 386 +++++++++++++-------------
 7 files changed, 497 insertions(+), 505 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/js/test/server_http.js
----------------------------------------------------------------------
diff --git a/lib/js/test/server_http.js b/lib/js/test/server_http.js
index ce09afc..e195e80 100644
--- a/lib/js/test/server_http.js
+++ b/lib/js/test/server_http.js
@@ -1,53 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-//This HTTP server is designed to server the test.html browser
-//  based JavaScript test page (which must be in the current directory). 
-//  This server also supplies the Thrift based test service, which depends
-//  on the standard ThriftTest.thrift IDL service (which must be compiled
-//  for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
-//  respectively). The current directory must also include the browser
-//  support libraries for test.html (jquery.js, qunit.js and qunit.css
-//  in ./build/js/lib).
-
-var thrift = require('../../nodejs/lib/thrift');
-var TBufferedTransport = require('../../nodejs/lib/thrift/transport').TBufferedTransport;
-var TJSONProtocol = require('../../nodejs/lib/thrift/protocol').TJSONProtocol;
-var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
-
-var ThriftTestSvcOpt = {
-	transport: TBufferedTransport,
-	protocol: TJSONProtocol,
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//This HTTP server is designed to serve the test.html browser
+//  based JavaScript test page (which must be in the current directory). 
+//  This server also supplies the Thrift based test service, which depends
+//  on the standard ThriftTest.thrift IDL service (which must be compiled
+//  for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
+//  respectively). 
+
+var thrift = require('../../nodejs/lib/thrift');
+var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
+var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
+
+var ThriftTestSvcOpt = {
+	transport: thrift.TBufferedTransport,
+	protocol: thrift.TJSONProtocol,
 	processor: ThriftTestSvc,
-	handler: ThriftTestHandler
-};
-
-var ThriftWebServerOptions = {
+	handler: ThriftTestHandler
+};
+
+var ThriftWebServerOptions = {
 	files: ".",
-	services: {
-		"/service": ThriftTestSvcOpt
-	}
-};
-
-var server = thrift.createWebServer(ThriftWebServerOptions);
-var port = 8088;
-server.listen(port);
-console.log("Serving files from: " + __dirname);
-console.log("Http/Thrift Server running on port: " + port);
+	services: {
+		"/service": ThriftTestSvcOpt
+	}
+};
+
+var server = thrift.createWebServer(ThriftWebServerOptions);
+var port = 8088;
+server.listen(port);
+console.log("Serving files from: " + __dirname);
+console.log("Http/Thrift Server running on port: " + port);

http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/js/test/server_https.js
----------------------------------------------------------------------
diff --git a/lib/js/test/server_https.js b/lib/js/test/server_https.js
index 69d7e89..af1745b 100644
--- a/lib/js/test/server_https.js
+++ b/lib/js/test/server_https.js
@@ -1,47 +1,45 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-//This HTTP server is designed to server the test.html browser
-//  based JavaScript test page (which must be in the current directory). 
-//  This server also supplies the Thrift based test service, which depends
-//  on the standard ThriftTest.thrift IDL service (which must be compiled
-//  for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
-//  respectively). The current directory must also include the browser
-//  support libraries for test.html (jquery.js, qunit.js and qunit.css
-//  in ./build/js/lib).
-
-var fs = require("fs");
-var thrift = require('../../nodejs/lib/thrift');
-var TBufferedTransport = require('../../nodejs/lib/thrift/transport').TBufferedTransport;
-var TJSONProtocol = require('../../nodejs/lib/thrift/protocol').TJSONProtocol;
-var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
-
-//Setup the I/O stack options for the ThriftTest service
-var ThriftTestSvcOpt = {
-  transport: TBufferedTransport,
-  protocol: TJSONProtocol,
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//This HTTP server is designed to server the test.html browser
+//  based JavaScript test page (which must be in the current directory). 
+//  This server also supplies the Thrift based test service, which depends
+//  on the standard ThriftTest.thrift IDL service (which must be compiled
+//  for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
+//  respectively). The current directory must also include the browser
+//  support libraries for test.html (jquery.js, qunit.js and qunit.css
+//  in ./build/js/lib).
+
+var fs = require("fs");
+var thrift = require('../../nodejs/lib/thrift');
+var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
+var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
+
+//Setup the I/O stack options for the ThriftTest service
+var ThriftTestSvcOpt = {
+  transport: thrift.TBufferedTransport,
+  protocol: thrift.TJSONProtocol,
   processor: ThriftTestSvc,
   handler: ThriftTestHandler
-};
-
-var ThriftWebServerOptions = {
+};
+
+var ThriftWebServerOptions = {
   files: ".",
   tls: {
      key: fs.readFileSync("../../../test/keys/server.key"),
@@ -50,10 +48,10 @@ var ThriftWebServerOptions = {
   services: {
     "/service": ThriftTestSvcOpt
   }
-};
-
-var server = thrift.createWebServer(ThriftWebServerOptions);
-var port = 8089;
-server.listen(port);
-console.log("Serving files from: " + __dirname);
-console.log("Http/Thrift Server running on port: " + port);
+};
+
+var server = thrift.createWebServer(ThriftWebServerOptions);
+var port = 8089;
+server.listen(port);
+console.log("Serving files from: " + __dirname);
+console.log("Http/Thrift Server running on port: " + port);

http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/nodejs/README.md
----------------------------------------------------------------------
diff --git a/lib/nodejs/README.md b/lib/nodejs/README.md
index 5860865..22c7caa 100644
--- a/lib/nodejs/README.md
+++ b/lib/nodejs/README.md
@@ -27,7 +27,7 @@ under the License.
 
 ## Thrift Compiler
 
-You can compile nodejs sources by running the following:
+You can compile IDL sources for Node.js with the following command:
 
     thrift --gen js:node thrift_file
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/nodejs/examples/hello.html
----------------------------------------------------------------------
diff --git a/lib/nodejs/examples/hello.html b/lib/nodejs/examples/hello.html
index 0897ea9..fe85a7e 100644
--- a/lib/nodejs/examples/hello.html
+++ b/lib/nodejs/examples/hello.html
@@ -26,13 +26,13 @@
 </head>
 <body>
     <h1>Apache Thrift JavaScript Browser Client Demo</h1>
-    <p>This html file demonstrates Apache Thrift JavaScrpt RPC between a browser client to a node.js server. Clicking the button below will call the hello_func() hosted by the Apache Thrift server at localhost:8585. The file hello.js contains the JavaScript node.js server required. Here are the steps to get the example running:</p>
+    <p>This html file demonstrates Apache Thrift JavaScrpt RPC between a browser client to a node.js server. Clicking the buttons below will call the RPC functions hosted by the Apache Thrift server at localhost:8585. The file hello.js contains the JavaScript node.js server required. Here are the steps to get the example running:</p>
     <ol>
         <li>Install Node.js <pre><a href="http://nodejs.org">nodejs.org</a></pre></li>
         <li>Install Apache Thrift for node (note that the node package manager will create the node_modules folder in the current directory so make sure to run npm from the same directory as hello.js so that the server can find the Thrift libraries. This example requires Apache Thrift 0.9.2+) <pre>$ npm install thrift</pre></li>
         <li>Compile the hello.idl for JavaScript and Node.js (you'll need to have the Apache Thrift compiler installed for this step. This also needs to be executed in the same directory as hello.js because hello.js and hello.html look for the gen-nodejs and gen-js directories here.)<pre>$ thrift -gen js -gen js:node hello.thrift</pre></li>
         <li>Run the node server in the directory with the hello.html file<pre>$ node hello.js</pre></li>
-        <li>Copy the Apache Thrift JavaScript library, thrift.js, into the directory with this html file.<pre>$ cp ...../thrift.js .</pre>
+        <li>Copy the Apache Thrift JavaScript library, thrift.js, into the directory with this html file.<pre>$ cp ...../thrift.js . (you should be able to use Bower to install the browser based Apache Thrift library in the near future.)</pre>
         <li>Reload this page in a browser through the node server using using the URL: <pre>http://localhost:8585/hello.html</pre>then click a button below to make an RPC call</li>
     </ol>
     <button id="btn">Get Message from Node Server</button>
@@ -41,8 +41,8 @@
         document.getElementById("btn").addEventListener("click", getMessage, false);
 
         function getMessage() {
-            var transport = new Thrift.Transport("http://localhost:8585/hello");
-            var protocol  = new Thrift.Protocol(transport);
+            var transport = new Thrift.TXHRTransport("http://localhost:8585/hello");
+            var protocol  = new Thrift.TJSONProtocol(transport);
             var client = new HelloSvcClient(protocol);
             var msg = client.hello_func();
             document.getElementById("output").innerHTML = msg;
@@ -51,8 +51,8 @@
         document.getElementById("btnDbl").addEventListener("click", dblMessage, false);
 
         function dblMessage() {
-            var transport = new Thrift.Transport("http://localhost:8585/dbl");
-            var protocol  = new Thrift.Protocol(transport);
+            var transport = new Thrift.TXHRTransport("http://localhost:8585/dbl");
+            var protocol  = new Thrift.TJSONProtocol(transport);
             var client = new TimesTwoClient(protocol);
             var val = client.dbl(25);
             document.getElementById("output2").innerHTML = val;

http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/nodejs/examples/hello.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/examples/hello.js b/lib/nodejs/examples/hello.js
index 90634c9..8b7c4e4 100644
--- a/lib/nodejs/examples/hello.js
+++ b/lib/nodejs/examples/hello.js
@@ -17,8 +17,6 @@
  * under the License.
  */
 var thrift = require('thrift');
-var TBufferedTransport = require('thrift/transport').TBufferedTransport;
-var TJSONProtocol = require('thrift/protocol').TJSONProtocol;
 var HelloSvc = require('./gen-nodejs/HelloSvc.js');
 var TimesTwoSvc = require('./gen-nodejs/TimesTwo.js');
 
@@ -38,28 +36,28 @@ var timesTwoHandler = {
 }
 
 var helloService = {
-	transport: TBufferedTransport,
-	protocol: TJSONProtocol,
-	cls: HelloSvc,
+	transport: thrift.TBufferedTransport,
+	protocol: thrift.TJSONProtocol,
+	processor: HelloSvc,
 	handler: helloHandler
 };
 
 var dblService = {
-	transport: TBufferedTransport,
-	protocol: TJSONProtocol,
-	cls: TimesTwoSvc,
+	transport: thrift.TBufferedTransport,
+	protocol: thrift.TJSONProtocol,
+	processor: TimesTwoSvc,
 	handler: timesTwoHandler
 };
 
-var StaticHttpThriftServerOptions = {
-	staticFilePath: ".",
+var ServerOptions = {
+	files: ".",
 	services: {
 		"/hello": helloService,
 		"/dbl": dblService,
 	}
 }
 
-var server = thrift.createStaticHttpThriftServer(StaticHttpThriftServerOptions);
+var server = thrift.createWebServer(ServerOptions);
 var port = 8585;
 server.listen(port);
 console.log("Http/Thrift Server running on port: " + port);

http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/nodejs/test/test_handler.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/test_handler.js b/lib/nodejs/test/test_handler.js
index ea1dc1d..3de8965 100644
--- a/lib/nodejs/test/test_handler.js
+++ b/lib/nodejs/test/test_handler.js
@@ -1,195 +1,195 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * 'License'); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-//This is the server side Node test handler for the standard 
-//  Apache Thrift test service.
-
-var ttypes = require('./gen-nodejs/ThriftTest_types');
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//This is the server side Node test handler for the standard 
+//  Apache Thrift test service.
+
+var ttypes = require('./gen-nodejs/ThriftTest_types');
 var TException = require('thrift').Thrift.TException;
-
-var ThriftTestHandler = exports.ThriftTestHandler = {
-  testVoid: function(result) {
-    console.log('testVoid()');
-    result(null);
-  },
-  testString: function(thing, result) {
-    console.log('testString(\'' + thing + '\')');
-    result(null, thing);
-  },
-  testByte: function(thing, result) {
-    console.log('testByte(' + thing + ')');
-    result(null, thing);
-  },
-  testI32: function(thing, result) {
-    console.log('testI32(' + thing + ')');
-    result(null, thing);
-  },
-  testI64: function(thing, result) {
-    console.log('testI64(' + thing + ')');
-    result(null, thing);
-  },
-  testDouble: function(thing, result) {
-    console.log('testDouble(' + thing + ')');
-    result(null, thing);
-  },
-  testStruct: function(thing, result) {
-    console.log('testStruct(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testNest: function(nest, result) {
-    console.log('testNest(');
-    console.log(nest);
-    console.log(')');
-    result(null, nest);
-  },
-  testMap: function(thing, result) {
-    console.log('testMap(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testStringMap: function(thing, result) {
-    console.log('testStringMap(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testSet: function(thing, result) {
-    console.log('testSet(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testList: function(thing, result) {
-    console.log('testList(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testEnum: function(thing, result) {
-    console.log('testEnum(' + thing + ')');
-    result(null, thing);
-  },
-  testTypedef: function(thing, result) {
-    console.log('testTypedef(' + thing + ')');
-    result(null, thing);
-  },
-  testMapMap: function(hello, result) {
-    console.log('testMapMap(' + hello + ')');
-
-    var mapmap = [];
-    var pos = [];
-    var neg = [];
-    for (var i = 1; i < 5; i++) {
-      pos[i] = i;
-      neg[-i] = -i;
-    }
-    mapmap[4] = pos;
-    mapmap[-4] = neg;
-
-    result(null, mapmap);
-  },
-  testInsanity: function(argument, result) {
-    console.log('testInsanity(');
-    console.log(argument);
-    console.log(')');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = 2;
-    hello.i32_thing = 2;
-    hello.i64_thing = 2;
-
-    var goodbye = new ttypes.Xtruct();
-    goodbye.string_thing = 'Goodbye4';
-    goodbye.byte_thing = 4;
-    goodbye.i32_thing = 4;
-    goodbye.i64_thing = 4;
-
-    var crazy = new ttypes.Insanity();
-    crazy.userMap = [];
-    crazy.userMap[ttypes.Numberz.EIGHT] = 8;
-    crazy.userMap[ttypes.Numberz.FIVE] = 5;
-    crazy.xtructs = [goodbye, hello];
-
-    var first_map = [];
-    var second_map = [];
-
-    first_map[ttypes.Numberz.TWO] = crazy;
-    first_map[ttypes.Numberz.THREE] = crazy;
-
-    var looney = new ttypes.Insanity();
-    second_map[ttypes.Numberz.SIX] = looney;
-
-    var insane = [];
-    insane[1] = first_map;
-    insane[2] = second_map;
-
-    console.log('insane result:');
-    console.log(insane);
-    result(null, insane);
-  },
-  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
-    console.log('testMulti()');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = arg0;
-    hello.i32_thing = arg1;
-    hello.i64_thing = arg2;
-    result(null, hello);
-  },
-  testException: function(arg, result) {
-    console.log('testException('+arg+')');
-    if (arg === 'Xception') {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = arg;
-      result(x);
-    } else if (arg === 'TException') {
-      result(new TException(arg));
-    } else {
-      result(null);
-    }
-  },
-  testMultiException: function(arg0, arg1, result) {
-    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
-    if (arg0 === ('Xception')) {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = 'This is an Xception';
-      result(x);
-    } else if (arg0 === ('Xception2')) {
-      var x2 = new ttypes.Xception2();
-      x2.errorCode = 2002;
-      x2.struct_thing = new ttypes.Xtruct();
-      x2.struct_thing.string_thing = 'This is an Xception2';
-      result(x2);
-    }
-
-    var res = new ttypes.Xtruct();
-    res.string_thing = arg1;
-    result(null, res);
-  },
-  testOneway: function(sleepFor, result) {
-    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
-  }
-};   //ThriftTestSvcHandler
+
+var ThriftTestHandler = exports.ThriftTestHandler = {
+  testVoid: function(result) {
+    console.log('testVoid()');
+    result(null);
+  },
+  testString: function(thing, result) {
+    console.log('testString(\'' + thing + '\')');
+    result(null, thing);
+  },
+  testByte: function(thing, result) {
+    console.log('testByte(' + thing + ')');
+    result(null, thing);
+  },
+  testI32: function(thing, result) {
+    console.log('testI32(' + thing + ')');
+    result(null, thing);
+  },
+  testI64: function(thing, result) {
+    console.log('testI64(' + thing + ')');
+    result(null, thing);
+  },
+  testDouble: function(thing, result) {
+    console.log('testDouble(' + thing + ')');
+    result(null, thing);
+  },
+  testStruct: function(thing, result) {
+    console.log('testStruct(');
+    console.log(thing);
+    console.log(')');
+    result(null, thing);
+  },
+  testNest: function(nest, result) {
+    console.log('testNest(');
+    console.log(nest);
+    console.log(')');
+    result(null, nest);
+  },
+  testMap: function(thing, result) {
+    console.log('testMap(');
+    console.log(thing);
+    console.log(')');
+    result(null, thing);
+  },
+  testStringMap: function(thing, result) {
+    console.log('testStringMap(');
+    console.log(thing);
+    console.log(')');
+    result(null, thing);
+  },
+  testSet: function(thing, result) {
+    console.log('testSet(');
+    console.log(thing);
+    console.log(')');
+    result(null, thing);
+  },
+  testList: function(thing, result) {
+    console.log('testList(');
+    console.log(thing);
+    console.log(')');
+    result(null, thing);
+  },
+  testEnum: function(thing, result) {
+    console.log('testEnum(' + thing + ')');
+    result(null, thing);
+  },
+  testTypedef: function(thing, result) {
+    console.log('testTypedef(' + thing + ')');
+    result(null, thing);
+  },
+  testMapMap: function(hello, result) {
+    console.log('testMapMap(' + hello + ')');
+
+    var mapmap = [];
+    var pos = [];
+    var neg = [];
+    for (var i = 1; i < 5; i++) {
+      pos[i] = i;
+      neg[-i] = -i;
+    }
+    mapmap[4] = pos;
+    mapmap[-4] = neg;
+
+    result(null, mapmap);
+  },
+  testInsanity: function(argument, result) {
+    console.log('testInsanity(');
+    console.log(argument);
+    console.log(')');
+
+    var hello = new ttypes.Xtruct();
+    hello.string_thing = 'Hello2';
+    hello.byte_thing = 2;
+    hello.i32_thing = 2;
+    hello.i64_thing = 2;
+
+    var goodbye = new ttypes.Xtruct();
+    goodbye.string_thing = 'Goodbye4';
+    goodbye.byte_thing = 4;
+    goodbye.i32_thing = 4;
+    goodbye.i64_thing = 4;
+
+    var crazy = new ttypes.Insanity();
+    crazy.userMap = [];
+    crazy.userMap[ttypes.Numberz.EIGHT] = 8;
+    crazy.userMap[ttypes.Numberz.FIVE] = 5;
+    crazy.xtructs = [goodbye, hello];
+
+    var first_map = [];
+    var second_map = [];
+
+    first_map[ttypes.Numberz.TWO] = crazy;
+    first_map[ttypes.Numberz.THREE] = crazy;
+
+    var looney = new ttypes.Insanity();
+    second_map[ttypes.Numberz.SIX] = looney;
+
+    var insane = [];
+    insane[1] = first_map;
+    insane[2] = second_map;
+
+    console.log('insane result:');
+    console.log(insane);
+    result(null, insane);
+  },
+  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
+    console.log('testMulti()');
+
+    var hello = new ttypes.Xtruct();
+    hello.string_thing = 'Hello2';
+    hello.byte_thing = arg0;
+    hello.i32_thing = arg1;
+    hello.i64_thing = arg2;
+    result(null, hello);
+  },
+  testException: function(arg, result) {
+    console.log('testException('+arg+')');
+    if (arg === 'Xception') {
+      var x = new ttypes.Xception();
+      x.errorCode = 1001;
+      x.message = arg;
+      result(x);
+    } else if (arg === 'TException') {
+      result(new TException(arg));
+    } else {
+      result(null);
+    }
+  },
+  testMultiException: function(arg0, arg1, result) {
+    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
+    if (arg0 === ('Xception')) {
+      var x = new ttypes.Xception();
+      x.errorCode = 1001;
+      x.message = 'This is an Xception';
+      result(x);
+    } else if (arg0 === ('Xception2')) {
+      var x2 = new ttypes.Xception2();
+      x2.errorCode = 2002;
+      x2.struct_thing = new ttypes.Xtruct();
+      x2.struct_thing.string_thing = 'This is an Xception2';
+      result(x2);
+    }
+
+    var res = new ttypes.Xtruct();
+    res.string_thing = arg1;
+    result(null, res);
+  },
+  testOneway: function(sleepFor, result) {
+    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
+  }
+};   //ThriftTestSvcHandler

http://git-wip-us.apache.org/repos/asf/thrift/blob/a2e4e565/lib/nodejs/test/test_handler_promise.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/test_handler_promise.js b/lib/nodejs/test/test_handler_promise.js
index c1561bc..385b04c 100644
--- a/lib/nodejs/test/test_handler_promise.js
+++ b/lib/nodejs/test/test_handler_promise.js
@@ -1,194 +1,194 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * 'License'); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-//This is the server side Node test handler for the standard
-//  Apache Thrift test service.
-
-var ttypes = require('./gen-nodejs/ThriftTest_types');
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//This is the server side Node test handler for the standard
+//  Apache Thrift test service.
+
+var ttypes = require('./gen-nodejs/ThriftTest_types');
 var TException = require('thrift').Thrift.TException;
-
-var ThriftTestHandler = exports.ThriftTestHandler = {
-  testVoid: function() {
-    console.log('testVoid()');
-  },
-  testString: function(thing) {
-    console.log('testString(\'' + thing + '\')');
-    return thing;
-  },
-  testByte: function(thing) {
-    console.log('testByte(' + thing + ')');
-    return thing;
-  },
-  testI32: function(thing) {
-    console.log('testI32(' + thing + ')');
-    return thing;
-  },
-  testI64: function(thing) {
-    console.log('testI64(' + thing + ')');
-    return thing;
-  },
-  testDouble: function(thing) {
-    console.log('testDouble(' + thing + ')');
-    return thing;
-  },
-  testStruct: function(thing) {
-    console.log('testStruct(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testNest: function(nest) {
-    console.log('testNest(');
-    console.log(nest);
-    console.log(')');
-    return nest;
-  },
-  testMap: function(thing) {
-    console.log('testMap(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testStringMap: function(thing) {
-    console.log('testStringMap(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testSet: function(thing, result) {
-    console.log('testSet(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testList: function(thing) {
-    console.log('testList(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testEnum: function(thing) {
-    console.log('testEnum(' + thing + ')');
-    return thing;
-  },
-  testTypedef: function(thing) {
-    console.log('testTypedef(' + thing + ')');
-    return thing;
-  },
-  testMapMap: function(hello) {
-    console.log('testMapMap(' + hello + ')');
-
-    var mapmap = [];
-    var pos = [];
-    var neg = [];
-    for (var i = 1; i < 5; i++) {
-      pos[i] = i;
-      neg[-i] = -i;
-    }
-    mapmap[4] = pos;
-    mapmap[-4] = neg;
-
-    return mapmap;
-  },
-  testInsanity: function(argument) {
-    console.log('testInsanity(');
-    console.log(argument);
-    console.log(')');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = 2;
-    hello.i32_thing = 2;
-    hello.i64_thing = 2;
-
-    var goodbye = new ttypes.Xtruct();
-    goodbye.string_thing = 'Goodbye4';
-    goodbye.byte_thing = 4;
-    goodbye.i32_thing = 4;
-    goodbye.i64_thing = 4;
-
-    var crazy = new ttypes.Insanity();
-    crazy.userMap = [];
-    crazy.userMap[ttypes.Numberz.EIGHT] = 8;
-    crazy.userMap[ttypes.Numberz.FIVE] = 5;
-    crazy.xtructs = [goodbye, hello];
-
-    var first_map = [];
-    var second_map = [];
-
-    first_map[ttypes.Numberz.TWO] = crazy;
-    first_map[ttypes.Numberz.THREE] = crazy;
-
-    var looney = new ttypes.Insanity();
-    second_map[ttypes.Numberz.SIX] = looney;
-
-    var insane = [];
-    insane[1] = first_map;
-    insane[2] = second_map;
-
-    console.log('insane result:');
-    console.log(insane);
-    return insane;
-  },
-  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5) {
-    console.log('testMulti()');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = arg0;
-    hello.i32_thing = arg1;
-    hello.i64_thing = arg2;
-    return hello;
-  },
-  testException: function(arg) {
-    console.log('testException('+arg+')');
-    if (arg === 'Xception') {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = arg;
-      throw x;
-    } else if (arg === 'TException') {
-      throw new TException(arg);
-    } else {
-      return;
-    }
-  },
-  testMultiException: function(arg0, arg1) {
-    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
-    if (arg0 === ('Xception')) {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = 'This is an Xception';
-      throw x;
-    } else if (arg0 === ('Xception2')) {
-      var x2 = new ttypes.Xception2();
-      x2.errorCode = 2002;
-      x2.struct_thing = new ttypes.Xtruct();
-      x2.struct_thing.string_thing = 'This is an Xception2';
-      throw x2;
-    }
-
-    var res = new ttypes.Xtruct();
-    res.string_thing = arg1;
-    return res;
-  },
-  testOneway: function(sleepFor) {
-    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
-  }
-};   //ThriftTestSvcHandler
+
+var ThriftTestHandler = exports.ThriftTestHandler = {
+  testVoid: function() {
+    console.log('testVoid()');
+  },
+  testString: function(thing) {
+    console.log('testString(\'' + thing + '\')');
+    return thing;
+  },
+  testByte: function(thing) {
+    console.log('testByte(' + thing + ')');
+    return thing;
+  },
+  testI32: function(thing) {
+    console.log('testI32(' + thing + ')');
+    return thing;
+  },
+  testI64: function(thing) {
+    console.log('testI64(' + thing + ')');
+    return thing;
+  },
+  testDouble: function(thing) {
+    console.log('testDouble(' + thing + ')');
+    return thing;
+  },
+  testStruct: function(thing) {
+    console.log('testStruct(');
+    console.log(thing);
+    console.log(')');
+    return thing;
+  },
+  testNest: function(nest) {
+    console.log('testNest(');
+    console.log(nest);
+    console.log(')');
+    return nest;
+  },
+  testMap: function(thing) {
+    console.log('testMap(');
+    console.log(thing);
+    console.log(')');
+    return thing;
+  },
+  testStringMap: function(thing) {
+    console.log('testStringMap(');
+    console.log(thing);
+    console.log(')');
+    return thing;
+  },
+  testSet: function(thing, result) {
+    console.log('testSet(');
+    console.log(thing);
+    console.log(')');
+    return thing;
+  },
+  testList: function(thing) {
+    console.log('testList(');
+    console.log(thing);
+    console.log(')');
+    return thing;
+  },
+  testEnum: function(thing) {
+    console.log('testEnum(' + thing + ')');
+    return thing;
+  },
+  testTypedef: function(thing) {
+    console.log('testTypedef(' + thing + ')');
+    return thing;
+  },
+  testMapMap: function(hello) {
+    console.log('testMapMap(' + hello + ')');
+
+    var mapmap = [];
+    var pos = [];
+    var neg = [];
+    for (var i = 1; i < 5; i++) {
+      pos[i] = i;
+      neg[-i] = -i;
+    }
+    mapmap[4] = pos;
+    mapmap[-4] = neg;
+
+    return mapmap;
+  },
+  testInsanity: function(argument) {
+    console.log('testInsanity(');
+    console.log(argument);
+    console.log(')');
+
+    var hello = new ttypes.Xtruct();
+    hello.string_thing = 'Hello2';
+    hello.byte_thing = 2;
+    hello.i32_thing = 2;
+    hello.i64_thing = 2;
+
+    var goodbye = new ttypes.Xtruct();
+    goodbye.string_thing = 'Goodbye4';
+    goodbye.byte_thing = 4;
+    goodbye.i32_thing = 4;
+    goodbye.i64_thing = 4;
+
+    var crazy = new ttypes.Insanity();
+    crazy.userMap = [];
+    crazy.userMap[ttypes.Numberz.EIGHT] = 8;
+    crazy.userMap[ttypes.Numberz.FIVE] = 5;
+    crazy.xtructs = [goodbye, hello];
+
+    var first_map = [];
+    var second_map = [];
+
+    first_map[ttypes.Numberz.TWO] = crazy;
+    first_map[ttypes.Numberz.THREE] = crazy;
+
+    var looney = new ttypes.Insanity();
+    second_map[ttypes.Numberz.SIX] = looney;
+
+    var insane = [];
+    insane[1] = first_map;
+    insane[2] = second_map;
+
+    console.log('insane result:');
+    console.log(insane);
+    return insane;
+  },
+  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5) {
+    console.log('testMulti()');
+
+    var hello = new ttypes.Xtruct();
+    hello.string_thing = 'Hello2';
+    hello.byte_thing = arg0;
+    hello.i32_thing = arg1;
+    hello.i64_thing = arg2;
+    return hello;
+  },
+  testException: function(arg) {
+    console.log('testException('+arg+')');
+    if (arg === 'Xception') {
+      var x = new ttypes.Xception();
+      x.errorCode = 1001;
+      x.message = arg;
+      throw x;
+    } else if (arg === 'TException') {
+      throw new TException(arg);
+    } else {
+      return;
+    }
+  },
+  testMultiException: function(arg0, arg1) {
+    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
+    if (arg0 === ('Xception')) {
+      var x = new ttypes.Xception();
+      x.errorCode = 1001;
+      x.message = 'This is an Xception';
+      throw x;
+    } else if (arg0 === ('Xception2')) {
+      var x2 = new ttypes.Xception2();
+      x2.errorCode = 2002;
+      x2.struct_thing = new ttypes.Xtruct();
+      x2.struct_thing.string_thing = 'This is an Xception2';
+      throw x2;
+    }
+
+    var res = new ttypes.Xtruct();
+    res.string_thing = arg1;
+    return res;
+  },
+  testOneway: function(sleepFor) {
+    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
+  }
+};   //ThriftTestSvcHandler