[Groonga-commit] groonga/express-kotoumi [master] Implement envelope based on the format discussed at #2

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Thu Jan 10 17:41:02 JST 2013


YUKI Hiroshi	2013-01-10 17:41:02 +0900 (Thu, 10 Jan 2013)

  New Revision: 302d0305f449b1226f6b63ec12b54cb92055094e
  https://github.com/groonga/express-kotoumi/commit/302d0305f449b1226f6b63ec12b54cb92055094e

  Log:
    Implement envelope based on the format discussed at #2

  Modified files:
    lib/backend-adaptor.js

  Modified: lib/backend-adaptor.js (+14 -5)
===================================================================
--- lib/backend-adaptor.js    2013-01-10 17:20:34 +0900 (49cfca1)
+++ lib/backend-adaptor.js    2013-01-10 17:41:02 +0900 (e5a112d)
@@ -77,16 +77,25 @@ function createId() {
   return Date.now() + ':' + Math.round(Math.random() * 65536);
 }
 
-Connection.prototype.emitMessage = function(message, callback) {
+function getCurrentTime() {
+  // The method toISOString() returns a GMT (ex. 2013-01-10T08:34:41.252Z)
+  // on node. However, a local time (ex. 2013-01-10T17:34:41.252+09:00) is
+  // more helpful for debugging. We should use it in the feature...
+  return new Date().toISOString();
+}
+
+Connection.prototype.emitMessage = function(body, callback) {
   var id = createId();
-  var message = {
-//    id:   id,
-    body: message
+  var envelope = {
+    id:         id,
+    date:       getCurrentTime(),
+    statusCode: 200,
+    body:       body
   };
   if (callback) {
     this.once('replyTo:' + id, callback);
   }
-  this._sender.emit('message', message);
+  this._sender.emit('message', envelope);
 };
 
 exports.Connection = Connection;
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る