[Groonga-commit] groonga/gcs [master] Build DomainStatus from domain information

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 1日 (水) 11:24:46 JST


piro	2012-08-01 11:24:46 +0900 (Wed, 01 Aug 2012)

  New Revision: 0ea48f40d6f7cbc3bd7818f1c94109a7ac13694a
  https://github.com/groonga/gcs/commit/0ea48f40d6f7cbc3bd7818f1c94109a7ac13694a

  Log:
    Build DomainStatus from domain information

  Modified files:
    lib/api/2011-02-01/configuration.js
    lib/database/domain.js

  Modified: lib/api/2011-02-01/configuration.js (+14 -26)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-07-31 15:09:05 +0900 (fcab6b8)
+++ lib/api/2011-02-01/configuration.js    2012-08-01 11:24:46 +0900 (da31258)
@@ -35,26 +35,26 @@ function createDomainStatus(options) {
     .element('Created').text(options.created || 'false').up()
     .element('Deleted').text(options.deleted || 'false').up()
     .element('DocService')
-      .element('Endpoint').text(options.documentsEndpoint || '').up()
+      .element('Endpoint').text(options.domain.getDocumentsEndpoint(options.hostname)).up()
     .up()
     .element('DomainId')
-      .text(options.domainId + '/' + options.domainName)
+      .text(options.domain.domainId)
     .up()
-    .element('DomainName').text(options.domainName).up()
+    .element('DomainName').text(options.domain.name).up()
     .element('NumSearchableDocs')
-      .text(options.searchableDocumentsCount || '0')
+      .text(options.domain.searchableDocumentsCount)
     .up()
     .element('RequiresIndexDocuments')
-      .text(options.requiresIndexDocuments || 'false')
+      .text(options.domain.requiresIndexDocuments)
     .up()
     .element('SearchInstanceCount')
-      .text(options.searchInstanceCount || '0')
+      .text(options.domain.searchInstanceCount)
     .up()
     .element('SearchPartitionCount')
-      .text(options.searchPartitionCount || '0')
+      .text(options.domain.searchPartitionCount)
     .up()
     .element('SearchService')
-      .element('Endpoint').text(options.searchEndpoint || '').up()
+      .element('Endpoint').text(options.domain.getSearchEndpoint(options.hostname)).up()
     .up();
   return domainStatus;
 }
@@ -80,15 +80,9 @@ handlers.CreateDomain = function(context, request, response) {
     host = host ? '.' + host : '';
     response.contentType('application/xml');
     response.send(createCreateDomainResponse({
-      domainName: domain.name,
-      domainId: domain.id,
-      searchEndpoint: 'search-' + domain.name + '-' + domain.id + host,
-      documentsEndpoint: 'doc-' + domain.name + '-' + domain.id + host,
-      created: true,
-      searchableDocumentsCount: 0,
-      searchInstanceCount: 0,
-      searchPartitionCount: 0,
-      requiresIndexDocuments: false
+      domain: domain,
+      hostname: host,
+      created: true
     }));
   } catch (error) {
     var body = createCommonErrorResponse('InternalFailure', error);
@@ -118,15 +112,9 @@ handlers.DeleteDomain = function(context, request, response) {
     host = host ? '.' + host : '';
     response.contentType('application/xml');
     response.send(createDeleteDomainResponse({
-      domainName: domain.name,
-      domainId: domain.id,
-      searchEndpoint: 'search-' + domain.name + '-' + domain.id + host,
-      documentsEndpoint: 'doc-' + domain.name + '-' + domain.id + host,
-      deleted: true,
-      searchableDocumentsCount: 0,
-      searchInstanceCount: 0,
-      searchPartitionCount: 0,
-      requiresIndexDocuments: false
+      domain: domain,
+      hostname: host,
+      deleted: true
     }));
   } catch (error) {
     var body = createCommonErrorResponse('InternalFailure', error.message);

  Modified: lib/database/domain.js (+23 -0)
===================================================================
--- lib/database/domain.js    2012-07-31 15:09:05 +0900 (75bc049)
+++ lib/database/domain.js    2012-08-01 11:24:46 +0900 (a971390)
@@ -124,6 +124,29 @@ Domain.prototype = {
   get id() {
     return FAKE_DOMAIN_ID;
   },
+  get domainId() {
+    return this.id + '/' + this.name;
+  },
+
+  get searchableDocumentsCount() {
+    return 0;
+  },
+  get requiresIndexDocuments() {
+    return false;
+  },
+  get searchInstanceCount() {
+    return 0;
+  },
+  get searchPartitionCount() {
+    return 0;
+  },
+
+  getDocumentsEndpoint: function(hostname) {
+    return 'doc-' + this.name + '-' + this.id + hostname;
+  },
+  getSearchEndpoint: function(hostname) {
+    return 'search-' + this.name + '-' + this.id + hostname;
+  },
 
   createSync: function() {
     if (!this.context)
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index