couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couch-index commit: updated refs/heads/windsor-merge to 6a12ce1
Date Thu, 07 Aug 2014 18:34:03 GMT
Repository: couchdb-couch-index
Updated Branches:
  refs/heads/windsor-merge 007d37e6a -> 6a12ce192


[WIP] Update couch_index_server to use couch_event


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/6a12ce19
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/6a12ce19
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/6a12ce19

Branch: refs/heads/windsor-merge
Commit: 6a12ce192e03187f0374b0ea711e633568b0512a
Parents: 007d37e
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Aug 7 13:30:41 2014 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Thu Aug 7 13:33:45 2014 -0500

----------------------------------------------------------------------
 src/couch_index_server.erl | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/6a12ce19/src/couch_index_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_server.erl b/src/couch_index_server.erl
index 7a6f883..146ed39 100644
--- a/src/couch_index_server.erl
+++ b/src/couch_index_server.erl
@@ -19,9 +19,11 @@
 -export([init/1, terminate/2, code_change/3]).
 -export([handle_call/3, handle_cast/2, handle_info/2]).
 
-% config_listener api
--export([handle_config_change/5]).
--export([handle_db_event/3]).
+% Exported for callbacks
+-export([
+    handle_config_change/5,
+    handle_db_event/3
+]).
 
 -include_lib("couch/include/couch_db.hrl").
 
@@ -245,5 +247,15 @@ handle_db_event(DbName, created, St) ->
 handle_db_event(DbName, deleted, St) ->
     gen_server:cast(?MODULE, {reset_indexes, DbName}),
     {ok, St};
+handle_db_event(DbName, {ddoc_updated, DDocId}, St) ->
+    lists:foreach(fun({_DbName, {_DDocId, Sig}}) ->
+        case ets:lookup(?BY_SIG, {DbName, Sig}) of
+            [{_, IndexPid}] ->
+                (catch gen_server:cast(IndexPid, ddoc_updated));
+            [] ->
+                ok
+        end
+    end, ets:match_object(?BY_DB, {DbName, {DDocId, '$1'}})),
+    {ok, St};
 handle_db_event(_DbName, _Event, St) ->
     {ok, St}.


Mime
View raw message