[Groonga-commit] groonga/gcs [master] Send requests without parameter validation

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Nov 9 12:46:14 JST 2012


YUKI Hiroshi	2012-11-09 12:46:14 +0900 (Fri, 09 Nov 2012)

  New Revision: 7ddc9c624a75d5f4dcfd969f6f1a4af2a0e3cacb
  https://github.com/groonga/gcs/commit/7ddc9c624a75d5f4dcfd969f6f1a4af2a0e3cacb

  Log:
    Send requests without parameter validation

  Modified files:
    bin/gcs-run-scenarios
    lib/client.js
    lib/command-line.js

  Modified: bin/gcs-run-scenarios (+2 -11)
===================================================================
--- bin/gcs-run-scenarios    2012-11-09 11:47:21 +0900 (0619cb4)
+++ bin/gcs-run-scenarios    2012-11-09 12:46:14 +0900 (e81a44d)
@@ -39,15 +39,6 @@ if (!commandLine.options.scenarios ||
 
 var scenarios = JSON.parse(fs.readFileSync(scenariosFile));
 
-cs = new CloudSearch({
-  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
-  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
-});
-
-CloudSearch.prototype.extractBody = function(options) {
-  return 'blob';
-};
-
 var statusCodeTable = {
   404: 'Not Found',
   400: 'Bad Request',
@@ -59,8 +50,8 @@ var resultsDir.resolve(resultsDirName, resultsDirectoryName);
 scenarios.forEach(function(scenario) {
   console.log('Processing ' + scenario.name);
   var filename = scenario.name.replace(/[^a-zA-Z0-9]+/g, '-') + '.txt';
-  cs[scenario.params.Action].call(cs, scenario.params, function(error, data) {
-    var response = error || data;
+  client.rawConfigurationRequest(scenario.params.Action, scenario.params, function(error, result) {
+    var response = error || result;
 
     var statusCode = response.StatusCode;
     if (!statusCodeTable[statusCode]) {

  Modified: lib/client.js (+50 -17)
===================================================================
--- lib/client.js    2012-11-09 11:47:21 +0900 (7b238cd)
+++ lib/client.js    2012-11-09 12:46:14 +0900 (4fcaaed)
@@ -3,11 +3,17 @@ var amazon = awssum.load('amazon/amazon');
 var CloudSearch = awssum.load('amazon/cloudsearch').CloudSearch;
 var DocumentService = awssum.load('amazon/cloudsearch').DocumentService;
 
+var OPTIONAL_PARAM = { required : false, type : 'param' };
+
+function sendRawDocumentRequest() {
+}
+
 function Client(options) {
   this.domainName = options.domainName;
   this.host = options.host;
   this.port = options.port;
   this.docEndpoint = options.docEndpoint;
+  this.isACS = options.isACS;
 
   this.accessKeyId     = options.accessKeyId;
   this.secretAccessKey = options.secretAccessKey;
@@ -19,14 +25,16 @@ Client.prototype = {
         accessKeyId:     this.accessKeyId,
         secretAccessKey: this.secretAccessKey
       });
-      var self = this;
-      this._configurationAPI.host = function() {
-        return self.host;
-      };
-      this._configurationAPI.addExtras = function(options, args) {
-        options.protocol = self.protocol || 'http';
-        options.port =  self.port;
-      };
+      if (!this.isACS) {
+        var self = this;
+        this._configurationAPI.host = function() {
+          return self.host;
+        };
+        this._configurationAPI.addExtras = function(options, args) {
+          options.protocol = self.protocol || 'http';
+          options.port =  self.port;
+        };
+      }
     }
     return this._configurationAPI;
   },
@@ -73,16 +81,18 @@ Client.prototype = {
       domainId: options.domainId,
       region: amazon.US_EAST_1
     });
-    var host = options.host;
-    service.host = function() {
-      return host;
-    };
-    var port = options.port;
     var self = this;
-    service.addExtras = function(options, args) {
-      options.protocol = self.protocol || 'http';
-      options.port =  port;
-    };
+    if (!this.isACS) {
+      var host = options.host;
+      service.host = function() {
+        return host;
+      };
+      var port = options.port;
+      service.addExtras = function(options, args) {
+        options.protocol = self.protocol || 'http';
+        options.port =  port;
+      };
+    }
     service.extractBody = function(options, args) {
       return 'json';
     };
@@ -113,6 +123,29 @@ Client.prototype = {
     process.exit(1);
   },
 
+  rawConfigurationRequest(action, params, callback) {
+    var extractBody = this.configurationAPI.extractBody;
+    this.extractBody = function() {
+      return 'blob';
+    };
+
+    var operation = {
+          defaults : {
+            Action: action
+          },
+          args : {}
+        };
+    Object.keys(params).forEach(function(name) {
+      operation.args[name] = OPTIONAL_PARAM;
+    });
+
+    var self = this;
+    this.configurationAPI.send(operation, params, null, function(error, result) {
+      self.configurationAPI.extractBody = extractBody;
+      callback(error, result);
+    });
+  },
+
   assertHaveDomainName: function() {
     if (!this.domainName)
       this.raiseFatalError('You must specify the domain name.');

  Modified: lib/command-line.js (+4 -0)
===================================================================
--- lib/command-line.js    2012-11-09 11:47:21 +0900 (8a94c09)
+++ lib/command-line.js    2012-11-09 12:46:14 +0900 (3562f79)
@@ -70,6 +70,10 @@ CommandLineInterface.prototype = {
     return this.options.secretAccessKey = value;
   },
 
+  get isACS() {
+    return this.options.acs;
+  },
+
   get databasePath() {
     return this.options.databasePath || defaultDatabasePath;
   },
-------------- next part --------------
HTML����������������������������...
Download 



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