[Groonga-commit] groonga/gcs [master] Accept port number as a part of base host and configuration host

Zurück zum Archiv-Index

SHIMODA Hiroshi null+****@clear*****
Wed Aug 15 15:54:08 JST 2012


SHIMODA Hiroshi	2012-08-15 15:54:08 +0900 (Wed, 15 Aug 2012)

  New Revision: 8b496774f25954bbad8144cbba94d057faf1fde1
  https://github.com/groonga/gcs/commit/8b496774f25954bbad8144cbba94d057faf1fde1

  Log:
    Accept port number as a part of base host and configuration host

  Modified files:
    bin/gcs
    lib/api/2011-02-01/configuration.js
    lib/command-line.js
    test/api-configuration.test.js
    test/test-utils.js

  Modified: bin/gcs (+2 -2)
===================================================================
--- bin/gcs    2012-08-15 15:36:20 +0900 (7942333)
+++ bin/gcs    2012-08-15 15:54:08 +0900 (7fe08f5)
@@ -15,12 +15,12 @@ commandLine
           String,
           CLI.defaultPrivilegedRanges)
   .option('--base-host <hostname>',
-          'The base host name assigned to this server '+
+          'The base host name assigned to the service '+
             '[' + CLI.defaultBaseHost + ']',
           String,
           CLI.defaultBaseHost)
   .option('--configuration-host <hostname>',
-          'The host name for configuration API of this server '+
+          'The host name for configuration API of the service '+
             '[' + CLI.defaultConfigurationHost + ']',
           String,
           CLI.defaultConfigurationHost)

  Modified: lib/api/2011-02-01/configuration.js (+8 -2)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-08-15 15:36:20 +0900 (5b44af5)
+++ lib/api/2011-02-01/configuration.js    2012-08-15 15:54:08 +0900 (91f87d4)
@@ -27,10 +27,16 @@ var handlers = Object.create(null);
 
 function getBaseHostAndPort(config) {
   var host = config.baseHost;
-  if (config.port == 80)
+  var port = config.port;
+  var portMatching = host.match(/:(\d+)$/);
+  if (portMatching) {
+    host = host.replace(portMatching[0], '');
+    port = parseInt(portMatching[1]);
+  }
+  if (port == 80)
     return host;
   else
-    return host + ':' + config.port;
+    return host + ':' + port;
 }
 
 function createDomainStatus(options) {

  Modified: lib/command-line.js (+2 -2)
===================================================================
--- lib/command-line.js    2012-08-15 15:36:20 +0900 (fb03857)
+++ lib/command-line.js    2012-08-15 15:54:08 +0900 (178b8f8)
@@ -12,10 +12,10 @@ var defaultPort =
       CommandLineInterface.defaultPort = 7575;
 var defaultBaseHost =
       exports.defaultBaseHost =
-      CommandLineInterface.defaultBaseHost = '127.0.0.1.xip.io';
+      CommandLineInterface.defaultBaseHost = '127.0.0.1.xip.io:' + defaultPort;
 var defaultConfigurationHost =
       exports.defaultConfigurationHost =
-      CommandLineInterface.defaultConfigurationHost = '127.0.0.1.xip.io';
+      CommandLineInterface.defaultConfigurationHost = '127.0.0.1.xip.io:' + defaultPort;
 var defaultPrivilegedRanges =
       exports.defaultPrivilegedRanges =
       CommandLineInterface.defaultPrivilegedRanges = '127.0.0.0/8';

  Modified: test/api-configuration.test.js (+4 -4)
===================================================================
--- test/api-configuration.test.js    2012-08-15 15:36:20 +0900 (6ab12fc)
+++ test/api-configuration.test.js    2012-08-15 15:54:08 +0900 (6d0b17e)
@@ -337,7 +337,7 @@ suite('Configuration API', function() {
               Created: 'true',
               Deleted: 'false',
               DocService: {
-                Endpoint: domain.getDocumentsEndpoint('localhost:' + utils.testPort)
+                Endpoint: domain.getDocumentsEndpoint('api.localhost')
               },
               DomainId: domain.domainId,
               DomainName: domain.name,
@@ -346,7 +346,7 @@ suite('Configuration API', function() {
               SearchInstanceCount: String(domain.searchInstanceCount),
               SearchPartitionCount: String(domain.searchPartitionCount),
               SearchService: {
-                Endpoint: domain.getSearchEndpoint('localhost:' + utils.testPort)
+                Endpoint: domain.getSearchEndpoint('api.localhost')
               }
             };
         var status = response.body.CreateDomainResponse.CreateDomainResult.DomainStatus;
@@ -383,7 +383,7 @@ suite('Configuration API', function() {
               Created: 'false',
               Deleted: 'true',
               DocService: {
-                Endpoint: domain.getDocumentsEndpoint('localhost:' + utils.testPort)
+                Endpoint: domain.getDocumentsEndpoint('api.localhost')
               },
               DomainId: domain.domainId,
               DomainName: domain.name,
@@ -392,7 +392,7 @@ suite('Configuration API', function() {
               SearchInstanceCount: String(domain.searchInstanceCount),
               SearchPartitionCount: String(domain.searchPartitionCount),
               SearchService: {
-                Endpoint: domain.getSearchEndpoint('localhost:' + utils.testPort)
+                Endpoint: domain.getSearchEndpoint('api.localhost')
               }
             };
         var status = response.body.DeleteDomainResponse.DeleteDomainResult.DomainStatus;

  Modified: test/test-utils.js (+2 -2)
===================================================================
--- test/test-utils.js    2012-08-15 15:36:20 +0900 (cd10396)
+++ test/test-utils.js    2012-08-15 15:54:08 +0900 (35be163)
@@ -11,8 +11,8 @@ var spawn = require('child_process').spawn;
 
 var temporaryDirectory = exports.temporaryDirectory = path.join(__dirname, 'tmp');
 
-var testBaseHost = 'localhost';
-var testConfigurationHost = 'configuration.localhost';
+var testBaseHost = 'api.localhost:80';
+var testConfigurationHost = 'configuration.localhost:80';
 var testPort = 3333;
 exports.testBaseHost = testBaseHost;
 exports.testConfigurationHost = testConfigurationHost;
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index