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/05 13:06:09 UTC

[08/21] couch commit: updated refs/heads/windsor-merge-119 to 9138d07

Update couch_changes to use 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/c24e6d68
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/c24e6d68
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/c24e6d68

Branch: refs/heads/windsor-merge-119
Commit: c24e6d6805d638879832fcf338bb42f2f201d104
Parents: be7b1a4
Author: Paul J. Davis <pa...@gmail.com>
Authored: Tue Apr 23 16:00:01 2013 -0500
Committer: Robert Newson <rn...@apache.org>
Committed: Mon Aug 4 15:19:30 2014 +0100

----------------------------------------------------------------------
 src/couch_changes.erl | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/c24e6d68/src/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_changes.erl b/src/couch_changes.erl
index fd14f3d..637a6ba 100644
--- a/src/couch_changes.erl
+++ b/src/couch_changes.erl
@@ -19,7 +19,8 @@
     wait_db_updated/3,
     get_rest_db_updated/1,
     configure_filter/4,
-    filter/3
+    filter/3,
+    handle_db_event/3
 ]).
 
 -export([changes_enumerator/2]).
@@ -77,13 +78,8 @@ handle_changes(Args1, Req, Db0) ->
     true ->
         fun(CallbackAcc) ->
             {Callback, UserAcc} = get_callback_acc(CallbackAcc),
-            Self = self(),
-            {ok, Notify} = couch_db_update_notifier:start_link(
-                fun({updated, DbName}) when Db0#db.name == DbName ->
-                    Self ! db_updated;
-                (_) ->
-                    ok
-                end
+            {ok, Listener} = couch_event:link_listener(
+                 ?MODULE, handle_db_event, self(), [{dbname, Db0#db.name}]
             ),
             {Db, StartSeq} = Start(),
             UserAcc2 = start_sending_changes(Callback, UserAcc, Feed),
@@ -96,7 +92,7 @@ handle_changes(Args1, Req, Db0) ->
                     Acc0,
                     true)
             after
-                couch_db_update_notifier:stop(Notify),
+                couch_event:stop_listener(Listener),
                 get_rest_db_updated(ok) % clean out any remaining update messages
             end
         end;
@@ -117,6 +113,15 @@ handle_changes(Args1, Req, Db0) ->
         end
     end.
 
+
+handle_db_event(_DbName, updated, Parent) ->
+    Parent ! db_updated,
+    {ok, Parent};
+
+handle_db_event(_DbName, _Event, Parent) ->
+    {ok, Parent}.
+
+
 get_callback_acc({Callback, _UserAcc} = Pair) when is_function(Callback, 3) ->
     Pair;
 get_callback_acc(Callback) when is_function(Callback, 2) ->