From f6fd760c17cb5d5d49211be4b4ff92e797e83157 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Sat, 4 Jul 2009 15:47:47 +0000 Subject: Name view index files by their function hashes for no downtime deploys. Closes COUCHDB-218 Adds ability to switch view indexes on the fly by building the index from a "staging" design doc, and then COPYing the staging doc to the production doc's id. Since indexes are referenced by view definition, the new version of the production design doc will point immediately to the index files already built in staging. Please use and give feedback. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791140 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch.js | 13 +++++++++++++ share/www/script/test/design_docs.js | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'share/www') diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 8f3d96ad..c4c1ae9f 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -177,6 +177,19 @@ function CouchDB(name, httpHeaders) { return JSON.parse(this.last_req.responseText); } + // gets information about a design doc + this.designInfo = function(docid) { + this.last_req = this.request("GET", this.uri + docid + "/_info"); + CouchDB.maybeThrowError(this.last_req); + return JSON.parse(this.last_req.responseText); + } + + this.viewCleanup = function() { + this.last_req = this.request("POST", this.uri + "_view_cleanup"); + CouchDB.maybeThrowError(this.last_req); + return JSON.parse(this.last_req.responseText); + } + this.allDocs = function(options,keys) { if(!keys) { this.last_req = this.request("GET", this.uri + "_all_docs" + encodeOptions(options)); diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js index 8f003efa..b1ff8432 100644 --- a/share/www/script/test/design_docs.js +++ b/share/www/script/test/design_docs.js @@ -49,6 +49,14 @@ function() { } T(db.save(designDoc).ok); + // test that we get design doc info back + var dinfo = db.designInfo("_design/test"); + TEquals("test", dinfo.name); + var vinfo = dinfo.view_index; + TEquals(51, vinfo.disk_size); + TEquals(false, vinfo.compact_running); + TEquals("64625dce94960fd5ca116e42aa9d011a", vinfo.signature); + db.bulkSave(makeDocs(1, numDocs + 1)); // test that the _all_docs view returns correctly with keys @@ -66,7 +74,7 @@ function() { T(db.ensureFullCommit().ok); restartServer(); }; - + // test when language not specified, Javascript is implied var designDoc2 = { _id:"_design/test2", @@ -110,5 +118,9 @@ function() { restartServer(); T(db.open(designDoc._id) == null); T(db.view("test/no_docs") == null); + + // trigger ddoc cleanup + T(db.viewCleanup().ok); + }); }; -- cgit v1.2.3