couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [08/20] couch commit: updated refs/heads/windsor-merge-102 to 944c542
Date Mon, 04 Aug 2014 22:18:10 GMT
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-102
Commit: c24e6d6805d638879832fcf338bb42f2f201d104
Parents: be7b1a4
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Apr 23 16:00:01 2013 -0500
Committer: Robert Newson <rnewson@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) ->


Mime
View raw message