[Groonga-commit] groonga/gcs-console [master] Follow gcs upstream change: stop to use Endpoint

Back to archive index

Yoji SHIDARA null+****@clear*****
Tue Dec 4 19:56:10 JST 2012


Yoji SHIDARA	2012-12-04 19:56:10 +0900 (Tue, 04 Dec 2012)

  New Revision: ed39a20a565faceb048099c43aef5bf1d5280c23
  https://github.com/groonga/gcs-console/commit/ed39a20a565faceb048099c43aef5bf1d5280c23

  Log:
    Follow gcs upstream change: stop to use Endpoint

  Modified files:
    bin/gcs-console
    routes/index.js
    test/test-utils.js

  Modified: bin/gcs-console (+1 -1)
===================================================================
--- bin/gcs-console    2012-12-04 18:48:15 +0900 (6782f40)
+++ bin/gcs-console    2012-12-04 19:56:10 +0900 (6af8cc4)
@@ -10,7 +10,7 @@ var app = express();
 
 var defaults = {
   port: process.env.GCS_CONSOLE_PORT || 7576,
-  endpoint: process.env.GCS_CONSOLE_ENDPOINT || 'http://localhost:7575',
+  endpoint: process.env.GCS_CONSOLE_ENDPOINT || 'http://127.0.0.1.xip.io:7575',
   gcsConsoleHome: process.env.GCS_CONSOLE_HOME || process.env.HOME + '/.gcs-console'
 }
 

  Modified: routes/index.js (+16 -4)
===================================================================
--- routes/index.js    2012-12-04 18:48:15 +0900 (7270553)
+++ routes/index.js    2012-12-04 19:56:10 +0900 (63d1098)
@@ -10,6 +10,12 @@ exports.index = function(req, res) {
   res.render('index', {action: 'index'});
 };
 
+function domainToEndpoint(configurationEndpoint, domain, type) {
+  var domainIdComponents = domain.DomainId.split('/');
+
+  return 'http://' + type + '-' + domainIdComponents[1] + '-' + domainIdComponents[0] + '.' + configurationEndpoint.hostname + ':' + configurationEndpoint.port;
+}
+
 function countBytes(string) {
   string = encodeURIComponent(string);
   var escapedPartsMatcher = /\%[0-9a-f][0-9a-f]/gi;
@@ -18,12 +24,16 @@ function countBytes(string) {
   return notEscapedParts.length + (escapedParts ? escapedParts.length : 0);
 }
 
-function createGcsDocumentService(domain) {
+function createGcsDocumentService(req, domain) {
   var documentService = new DocumentService({
     domainName: domain.DomainName,
     domainId: domain.DomainId
   });
-  var endpoint = url.parse('http://' + domain.DocService.Endpoint);
+  var configurationEndpoint = url.parse(req.app.get('endpoint'));
+  var endpoint = url.parse(
+    domainToEndpoint(configurationEndpoint, domain, 'doc')
+  );
+
   documentService.host = function() {
     return endpoint.hostname;
   };
@@ -43,7 +53,7 @@ function withDomain(req, res, callback) {
   domain.isSelected = true;
 
   req.domain = domain;
-  req.documentService = createGcsDocumentService(domain);
+  req.documentService = createGcsDocumentService(req, domain);
 
   // get index fields
   req.cloudsearch.DescribeIndexFields({
@@ -132,7 +142,9 @@ exports.domainSearch = function(req, res) {
       start: start,
       'return-fields': indexFieldNames.join(',')
     };
-    var requestURL = 'http://' + req.domain.SearchService.Endpoint + '/2011-02-01/search?' + querystring.stringify(paramsForSearch);
+
+    var configurationEndpoint = url.parse(req.app.get('endpoint'));
+    var requestURL = domainToEndpoint(configurationEndpoint, req.domain, 'search') + '/2011-02-01/search?' + querystring.stringify(paramsForSearch);
 
     var buffer = '';
     var results = null;

  Modified: test/test-utils.js (+1 -1)
===================================================================
--- test/test-utils.js    2012-12-04 18:48:15 +0900 (0e4ff2b)
+++ test/test-utils.js    2012-12-04 19:56:10 +0900 (cd0d81c)
@@ -41,7 +41,7 @@ Target.prototype = {
     ];
     var gcsConsoleOptions = [
       '--port', self.gcsConsolePort,
-      '--endpoint', 'http://localhost:' + self.gcsPort,
+      '--endpoint', 'http://127.0.0.1.xip.io:' + self.gcsPort,
       '--gcs-console-home', self.gcsConsoleHome
     ];
 
-------------- next part --------------
HTML����������������������������...
Download 



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