[Groonga-commit] droonga/express-droonga at c3d0e6a [master] Convert timeout seconds to milliseconds

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Apr 20 15:25:39 JST 2015


YUKI Hiroshi	2015-04-20 15:25:39 +0900 (Mon, 20 Apr 2015)

  New Revision: c3d0e6ac30a9e14889dbea2c667e24d7f4884388
  https://github.com/droonga/express-droonga/commit/c3d0e6ac30a9e14889dbea2c667e24d7f4884388

  Message:
    Convert timeout seconds to milliseconds

  Modified files:
    lib/droonga-protocol/connection.js

  Modified: lib/droonga-protocol/connection.js (+8 -5)
===================================================================
--- lib/droonga-protocol/connection.js    2015-04-20 15:23:46 +0900 (becb339)
+++ lib/droonga-protocol/connection.js    2015-04-20 15:25:39 +0900 (4b970a5)
@@ -37,9 +37,11 @@ var ERROR_GATEWAY_TIMEOUT =
       Connection.ERROR_GATEWAY_TIMEOUT =
         504;
 
-var DEFAULT_RESPONSE_TIMEOUT =
-      Connection.DEFAULT_RESPONSE_TIMEOUT =
-        60 * 1000;
+var ONE_SECOND_IN_MILLISECONDS = 1000;
+
+var DEFAULT_RESPONSE_TIMEOUT_SECONDS =
+      Connection.DEFAULT_RESPONSE_TIMEOUT_SECONDS =
+        60;
 
 function Connection(params) {
   EventEmitter.call(this);
@@ -264,8 +266,9 @@ Connection.prototype.emitMessage = function(type, body, callback, options) {
       }
     }).bind(this));
     options.timeout = toInteger(options.timeout) ||
-                        DEFAULT_RESPONSE_TIMEOUT;
+                        DEFAULT_RESPONSE_TIMEOUT_SECONDS;
     if (options.timeout > -1) {
+      var timeoutMilliseconds = options.timeout * ONE_SECOND_IN_MILLISECONDS;
       timeoutId = setTimeout((function() {
         this.removeAllListeners(event);
         if (sendingMessages)
@@ -279,7 +282,7 @@ Connection.prototype.emitMessage = function(type, body, callback, options) {
         catch(error) {
           this._logger.error(error);
         }
-      }).bind(this), options.timeout);
+      }).bind(this), timeoutMilliseconds);
     }
   }
   this._sendingMessages[id] = sendingMessages;
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index