You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 23:08:45 UTC

[31/32] git commit: Reject design docs with compilation errors

Reject design docs with compilation errors

If we know the language for a given design doc we'll attempt to compile
the map/reduce functions and reject updates that introduce code that
doesn't compile. We don't yet do the other types of functions because
those errors are more user visible.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/commit/fd046ec6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/fd046ec6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/fd046ec6

Branch: refs/heads/import
Commit: fd046ec62117b138e43d0e7d51a6aa57c93c7d09
Parents: 7bd5db6
Author: Paul J. Davis <pa...@gmail.com>
Authored: Sun Mar 10 16:03:00 2013 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Mar 20 06:02:54 2013 -0500

----------------------------------------------------------------------
 src/couch_index_server.erl | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/fd046ec6/src/couch_index_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_server.erl b/src/couch_index_server.erl
index a106f14..3d8a797 100644
--- a/src/couch_index_server.erl
+++ b/src/couch_index_server.erl
@@ -14,7 +14,7 @@
 -behaviour(gen_server).
 -behaviour(config_listener).
 
--export([start_link/0, get_index/4, get_index/3, get_index/2]).
+-export([start_link/0, validate/2, get_index/4, get_index/3, get_index/2]).
 -export([update_notify/1]).
 
 -export([init/1, terminate/2, code_change/3]).
@@ -35,6 +35,32 @@
 start_link() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
 
+
+validate(DbName, DDoc) ->
+    LoadModFun = fun
+        ({ModNameList, "true"}) ->
+            try
+                [list_to_existing_atom(ModNameList)]
+            catch error:badarg ->
+                []
+            end;
+        ({_ModNameList, _Enabled}) ->
+            []
+    end,
+    ValidateFun = fun
+        (ModName, ok) ->
+            try
+                ModName:validate(DbName, DDoc)
+            catch Type:Reason ->
+                {Type, Reason}
+            end;
+        (_ModName, Error) ->
+            Error
+    end,
+    EnabledIndexers = lists:flatmap(LoadModFun, config:get("indexers")),
+    lists:foldl(ValidateFun, ok, EnabledIndexers).
+
+
 get_index(Module, <<"shards/", _/binary>>=DbName, DDoc) ->
     {Pid, Ref} = spawn_monitor(fun() ->
         exit(fabric:open_doc(mem3:dbname(DbName), DDoc, []))