extract couch_httpd changes API in its own module
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/72589456 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/72589456 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/72589456 Branch: refs/heads/import-rcouch Commit: 725894562adc35e2c5e943085660bf85e0e6ccf6 Parents: b60ac21 Author: benoitc <bchesn...@gmail.com> Authored: Sun Feb 2 19:54:01 2014 +0100 Committer: Paul J. Davis <paul.joseph.da...@gmail.com> Committed: Thu Feb 6 10:51:40 2014 -0600 ---------------------------------------------------------------------- src/couch_index.erl | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/72589456/src/couch_index.erl ---------------------------------------------------------------------- diff --git a/src/couch_index.erl b/src/couch_index.erl index c09a110..c48c066 100644 --- a/src/couch_index.erl +++ b/src/couch_index.erl @@ -219,9 +219,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), @@ -242,12 +251,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} ->