[Groonga-commit] groonga/groonga-admin at 8575fef [master] Extract function to set thread_limit

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Sep 26 11:55:24 JST 2016


YUKI Hiroshi	2016-09-26 11:55:24 +0900 (Mon, 26 Sep 2016)

  New Revision: 8575fef75a8992c8229b0df09eab6b167a145cd1
  https://github.com/groonga/groonga-admin/commit/8575fef75a8992c8229b0df09eab6b167a145cd1

  Merged 9791dae: Merge pull request #14 from groonga/features/set-thread-limit-to-1

  Message:
    Extract function to set thread_limit

  Modified files:
    app/scripts/services/schema-loader.js

  Modified: app/scripts/services/schema-loader.js (+21 -23)
===================================================================
--- app/scripts/services/schema-loader.js    2016-09-26 11:54:59 +0900 (803685c)
+++ app/scripts/services/schema-loader.js    2016-09-26 11:55:24 +0900 (6014e7a)
@@ -186,39 +186,37 @@ angular.module('groongaAdminApp')
           });
       }
 
+      var THREAD_LIMIT_UNKNOWN = 0;
+      function setThreadLimit(limit) {
+        return client.execute('thread_limit', { max: limit })
+          .then(function(response) {
+            return response.lastMaxLimit();
+          }, function(errorResponse) {
+            return THREAD_LIMIT_UNKNOWN;
+          });
+      }
+
       function fetchSchema(schema) {
         schema.tables = {};
-        var lastMaxLimit;
-        return client.execute('thread_limit', { max: 1 })
-          .success(function(response) {
-            lastMaxLimit = response.lastMaxLimit();
-          })
-          .error(function() {
+        var lastMaxLimitBackup;
+        return setThreadLimit(1)
+          .then(function(lastMaxLimit) {
+            lastMaxLimitBackup = lastMaxLimit;
           })
           .then(function() {
             return client.execute('schema')
-                    .success(function(response) {
+                    .then(function(response) {
                       schema.types = buildTypes(response.types());
                       schema.tables = buildTables(response.tables());
                       resolveIndexes(schema);
-                      return schema;
-                    })
-                    .error(function() {
-                      return null;
-                    });
+                    }, function(errorResponse) {});
           })
-          .then(function(schema) {
-            if (!lastMaxLimit)
-              return schema;
-            return client.execute('thread_limit', { max: lastMaxLimit })
-                    .success(function(response) {
-                      return schema;
-                    })
-                    .error(function() {
-                      return schema;
-                    });
+          .then(function() {
+            if (lastMaxLimitBackup === THREAD_LIMIT_UNKNOWN)
+              return;
+            return setThreadLimit(lastMaxLimitBackup);
           })
-          .then(function(schema) {
+          .then(function() {
             fetched = true;
             fetching = false;
             waitingDeferes.forEach(function(defer) {
-------------- next part --------------
HTML����������������������������...
Download 



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