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/02/06 17:43:41 UTC
[10/12] couch-index commit: updated refs/heads/import-rcouch to
4a5a0e3
extract couch_httpd changes API in its own module
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/4a5a0e37
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/4a5a0e37
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/4a5a0e37
Branch: refs/heads/import-rcouch
Commit: 4a5a0e372843b2abc37ff351cf1dc51539075812
Parents: 16a974f
Author: benoitc <bc...@gmail.com>
Authored: Sun Feb 2 19:54:01 2014 +0100
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 10:41:51 2014 -0600
----------------------------------------------------------------------
src/couch_index.erl | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/4a5a0e37/src/couch_index.erl
----------------------------------------------------------------------
diff --git a/src/couch_index.erl b/src/couch_index.erl
index 7e38212..3f04f9d 100644
--- a/src/couch_index.erl
+++ b/src/couch_index.erl
@@ -221,9 +221,18 @@ handle_cast({new_state, NewIdxState}, State) ->
} = State,
assert_signature_match(Mod, OldIdxState, NewIdxState),
CurrSeq = Mod:get(update_seq, NewIdxState),
+
+ DbName = Mod:get(db_name, NewIdxState),
+ DDocId = Mod:get(idx_name, NewIdxState),
+
+ %% notify to event listeners that the index has been
+ %% updated
+ couch_index_event:notify({index_update,
+ {DbName, DDocId,
+ Mod}}),
Args = [
- Mod:get(db_name, NewIdxState),
- Mod:get(idx_name, NewIdxState),
+ DbName,
+ DDocId,
CurrSeq
],
?LOG_DEBUG("Updated index for db: ~s idx: ~s seq: ~B", Args),
@@ -244,12 +253,27 @@ handle_cast(stop, State) ->
{stop, normal, State};
handle_cast(delete, State) ->
#st{mod=Mod, idx_state=IdxState} = State,
+ DbName = Mod:get(db_name, IdxState),
+ DDocId = Mod:get(idx_name, IdxState),
+
ok = Mod:delete(IdxState),
+
+ %% notify about the index deletion
+ couch_index_event:notify({index_delete,
+ {DbName, DDocId, Mod}}),
+
{stop, normal, State};
handle_cast(ddoc_updated, State) ->
#st{mod = Mod, idx_state = IdxState, waiters = Waiters} = State,
DbName = Mod:get(db_name, IdxState),
DDocId = Mod:get(idx_name, IdxState),
+
+ %% notify to event listeners that the index has been
+ %% updated
+ couch_index_event:notify({index_update,
+ {DbName, DDocId,
+ Mod}}),
+
Shutdown = couch_util:with_db(DbName, fun(Db) ->
case couch_db:open_doc(Db, DDocId, [ejson_body]) of
{not_found, deleted} ->