You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/28 14:12:16 UTC
[2/5] couch-index commit: updated refs/heads/master to 9e638f6
[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/master
Commit: 6a12ce192e03187f0374b0ea711e633568b0512a
Parents: 007d37e
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Aug 7 13:30:41 2014 -0500
Committer: Paul J. Davis <pa...@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}.