couch_mrview: couch_mrview_changes:handle_changes Similar to couch_changes:handle_changes but for view changes. It add support for longpolling, normal and continuous stream The API differs from the one for doc by beeing independant from the transport: the support of HTTP will be added on top for example.
This API will be also used to replace the view filter in the current _changes API. Also add unittests. 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/b60ac211 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/b60ac211 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/b60ac211 Branch: refs/heads/import-rcouch Commit: b60ac211ca7b162048dc88bbf4da75c3c926a8d6 Parents: 5dbbdb5 Author: benoitc <beno...@apache.org> Authored: Fri Jan 31 13:13:23 2014 +0100 Committer: Paul J. Davis <paul.joseph.da...@gmail.com> Committed: Thu Feb 6 10:51:40 2014 -0600 ---------------------------------------------------------------------- src/couch_index_server.erl | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/b60ac211/src/couch_index_server.erl ---------------------------------------------------------------------- diff --git a/src/couch_index_server.erl b/src/couch_index_server.erl index 86791db..facde14 100644 --- a/src/couch_index_server.erl +++ b/src/couch_index_server.erl @@ -159,6 +159,8 @@ reset_indexes(DbName, Root) -> MRef = erlang:monitor(process, Pid), gen_server:cast(Pid, delete), receive {'DOWN', MRef, _, _, _} -> ok end, + couch_index_event:notify({index_delete, + {DbName, DDocId, couch_mrview_index}}), rem_from_ets(DbName, Sig, DDocId, Pid) end, lists:foreach(Fun, ets:lookup(?BY_DB, DbName)), @@ -193,6 +195,11 @@ update_notify({ddoc_updated, {DbName, DDocId}}) -> fun({_DbName, {_DDocId, Sig}}) -> case ets:lookup(?BY_SIG, {DbName, Sig}) of [{_, IndexPid}] -> + %% notify to event listeners that the index has been + %% updated + couch_index_event:notify({index_update, + {DbName, DDocId, + couch_mrview_index}}), (catch gen_server:cast(IndexPid, ddoc_updated)); [] -> ok