Switch notifications to the new couch_event app
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/2b45f92b Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/2b45f92b Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/2b45f92b Branch: refs/heads/windsor-merge-209 Commit: 2b45f92ba0f5c5de6eef1c65ee6252abb9f0ffb9 Parents: 088ded6 Author: Paul J. Davis <[email protected]> Authored: Wed Apr 24 12:42:14 2013 -0500 Committer: Robert Newson <[email protected]> Committed: Mon Aug 4 15:19:26 2014 +0100 ---------------------------------------------------------------------- src/couch_db_updater.erl | 24 ++++++++++++++---------- src/couch_server.erl | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2b45f92b/src/couch_db_updater.erl ---------------------------------------------------------------------- diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl index 1b20544..4e72dac 100644 --- a/src/couch_db_updater.erl +++ b/src/couch_db_updater.erl @@ -107,7 +107,7 @@ handle_call(cancel_compact, _From, #db{compactor_pid = Pid} = Db) -> handle_call(increment_update_seq, _From, Db) -> Db2 = commit_data(Db#db{update_seq=Db#db.update_seq+1}), ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), - couch_db_update_notifier:notify({updated, Db#db.name}), + couch_event:notify(Db#db.name, updated), {reply, {ok, Db2#db.update_seq}, Db2}; handle_call({set_security, NewSec}, _From, #db{compression = Comp} = Db) -> @@ -189,7 +189,7 @@ handle_call({purge_docs, IdRevs}, _From, Db) -> header=Header#db_header{purge_seq=PurgeSeq+1, purged_docs=Pointer}}), ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), - couch_db_update_notifier:notify({updated, Db#db.name}), + couch_event:notify(Db#db.name, updated), {reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2}. @@ -242,7 +242,7 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) -> close_db(Db), NewDb3 = refresh_validate_doc_funs(NewDb2), ok = gen_server:call(couch_server, {db_updated, NewDb3}, infinity), - couch_db_update_notifier:notify({compacted, NewDb3#db.name}), + couch_event:notify(NewDb3#db.name, compacted), ?LOG_INFO("Compaction for db \"~s\" completed.", [Db#db.name]), {noreply, NewDb3#db{compactor_pid=nil}}; false -> @@ -278,14 +278,19 @@ handle_info({update_docs, Client, GroupedDocs, NonRepDocs, MergeConflicts, {ok, Db2, UpdatedDDocIds} -> ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), if Db2#db.update_seq /= Db#db.update_seq -> - couch_db_update_notifier:notify({updated, Db2#db.name}); + couch_event:notify(Db2#db.name, updated); true -> ok end, [catch(ClientPid ! {done, self()}) || ClientPid <- Clients], - lists:foreach(fun(DDocId) -> - couch_db_update_notifier:notify({ddoc_updated, {Db#db.name, DDocId}}) - end, UpdatedDDocIds), - {noreply, Db2, hibernate} + Db3 = case length(UpdatedDDocIds) > 0 of + true -> + couch_event:notify(Db2#db.name, ddoc_updated), + ddoc_cache:evict(Db2#db.name, UpdatedDDocIds), + refresh_validate_doc_funs(Db2); + false -> + Db2 + end, + {noreply, Db3, hibernate} catch throw: retry -> [catch(ClientPid ! {retry, self()}) || ClientPid <- Clients], @@ -738,8 +743,7 @@ update_docs_int(Db, DocsList, NonRepDocs, MergeConflicts, FullCommit) -> % funs if we did. Db4 = case length(UpdatedDDocIds) > 0 of true -> - couch_db_update_notifier:notify( - {ddoc_updated, Db3#db.name}), + couch_event:notify(Db3#db.name, ddoc_updated), ddoc_cache:evict(Db3#db.name, UpdatedDDocIds), refresh_validate_doc_funs(Db3); false -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2b45f92b/src/couch_server.erl ---------------------------------------------------------------------- diff --git a/src/couch_server.erl b/src/couch_server.erl index e54efcc..5a73877 100644 --- a/src/couch_server.erl +++ b/src/couch_server.erl @@ -291,7 +291,7 @@ open_async(Server, From, DbName, Filepath, Options) -> Res = couch_db:start_link(DbName, Filepath, Options), case {Res, lists:member(create, Options)} of {{ok, _Db}, true} -> - couch_db_update_notifier:notify({created, DbName}); + couch_event:notify(DbName, created); _ -> ok end, @@ -456,7 +456,7 @@ handle_call({delete, DbName, Options}, _From, Server) -> case couch_file:delete(Server#server.root_dir, FullFilepath, Async) of ok -> - couch_db_update_notifier:notify({deleted, DbName}), + couch_event:notify(DbName, deleted), {reply, ok, Server2}; {error, enoent} -> {reply, not_found, Server2};
