couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [15/48] mem3 commit: updated refs/heads/windsor-merge to ff02b9a
Date Fri, 01 Aug 2014 09:11:01 GMT
Use a private record for event listener state


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/43cd763d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/43cd763d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/43cd763d

Branch: refs/heads/windsor-merge
Commit: 43cd763dcbda4889d65f0e0b0e2fea234e6be92c
Parents: 7706134
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Fri May 24 15:03:54 2013 -0400
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 23 18:46:25 2014 +0100

----------------------------------------------------------------------
 src/mem3_sync.erl | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/43cd763d/src/mem3_sync.erl
----------------------------------------------------------------------
diff --git a/src/mem3_sync.erl b/src/mem3_sync.erl
index 9c82c0e..3d975fc 100644
--- a/src/mem3_sync.erl
+++ b/src/mem3_sync.erl
@@ -25,6 +25,12 @@
 -include_lib("mem3/include/mem3.hrl").
 -include_lib("couch/include/couch_db.hrl").
 
+-record(event_listener, {
+    nodes,
+    shards,
+    users
+}).
+
 -record(state, {
     active = [],
     count = 0,
@@ -265,18 +271,22 @@ sync_push(ShardName, N) ->
     gen_server:call(mem3_sync, {push, #job{name=ShardName, node=N}}, infinity).
 
 start_event_listener() ->
-    State = {nodes_db(), shards_db(), users_db()},
+    State = #event_listener{
+        nodes = nodes_db(),
+        shards = shards_db(),
+        users = users_db()
+    },
     couch_event:link_listener(?MODULE, handle_db_event, State, [all_dbs]).
 
-handle_db_event(NodesDb, updated, {NodesDb, _, _}=St) ->
+handle_db_event(NodesDb, updated, #event_listener{nodes = NodesDb} = St) ->
     Nodes = mem3:nodes(),
     Live = nodes(),
     [?MODULE:push(NodesDb, N) || N <- Nodes, lists:member(N, Live)],
     {ok, St};
-handle_db_event(ShardsDb, updated, {_, ShardsDb, _}=St) ->
+handle_db_event(ShardsDb, updated, #event_listener{shards = ShardsDb} = St) ->
     ?MODULE:push(ShardsDb, find_next_node()),
     {ok, St};
-handle_db_event(UsersDb, updated, {_, _, UsersDb}=St) ->
+handle_db_event(UsersDb, updated, #event_listener{users = UsersDb} = St) ->
     ?MODULE:push(UsersDb, find_next_node()),
     {ok, St};
 handle_db_event(<<"shards/", _/binary>> = ShardName, updated, St) ->


Mime
View raw message