couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [01/10] ddoc-cache commit: updated refs/heads/master to 4ffc6b0
Date Thu, 28 Aug 2014 12:17:43 GMT
Repository: couchdb-ddoc-cache
Updated Branches:
  refs/heads/master f17c21fb6 -> 4ffc6b000


Update to use new couch_event application


Project: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/commit/41d82533
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/tree/41d82533
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/diff/41d82533

Branch: refs/heads/master
Commit: 41d82533aa59ca271619e822f4542faa5f3d028c
Parents: f17c21f
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Apr 23 17:05:55 2013 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jul 29 11:26:06 2014 +0100

----------------------------------------------------------------------
 src/ddoc_cache.app.src    |  1 +
 src/ddoc_cache_opener.erl | 24 +++++++++++++-----------
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/41d82533/src/ddoc_cache.app.src
----------------------------------------------------------------------
diff --git a/src/ddoc_cache.app.src b/src/ddoc_cache.app.src
index 55a108f..7d03bdf 100644
--- a/src/ddoc_cache.app.src
+++ b/src/ddoc_cache.app.src
@@ -28,6 +28,7 @@
         kernel,
         stdlib,
         crypto,
+        couch_event,
         ets_lru,
         mem3,
         fabric,

http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/41d82533/src/ddoc_cache_opener.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache_opener.erl b/src/ddoc_cache_opener.erl
index 0a0198e..c0a85b4 100644
--- a/src/ddoc_cache_opener.erl
+++ b/src/ddoc_cache_opener.erl
@@ -37,7 +37,7 @@
 ]).
 
 -export([
-    evictor/1
+    handle_db_event/3
 ]).
 
 
@@ -63,7 +63,9 @@ start_link() ->
 init(_) ->
     process_flag(trap_exit, true),
     ets:new(?OPENING, [set, protected, named_table, {keypos, #opener.key}]),
-    {ok, Evictor} = couch_db_update_notifier:start_link(fun ?MODULE:evictor/1),
+    {ok, Evictor} = couch_event:link_listener(
+            ?MODULE, handle_db_event, nil, [all_dbs]
+        ),
     {ok, #st{
         evictor = Evictor
     }}.
@@ -127,7 +129,7 @@ handle_cast(Msg, St) ->
 
 handle_info({'EXIT', Pid, Reason}, #st{evictor=Pid}=St) ->
     couch_log:error("ddoc_cache_opener evictor died ~w", [Reason]),
-    {ok, Evictor} = couch_db_update_notifier:start_link(fun ?MODULE:evictor/1),
+    {ok, Evictor} = couch_event:link_listener(?MODULE, evictor, nil, [all_dbs]),
     {noreply, St#st{evictor=Evictor}};
 
 handle_info({'EXIT', _Pid, {open_ok, Key, Resp}}, St) ->
@@ -157,14 +159,14 @@ code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
 
 
-evictor({created, ShardDbName}) ->
-    DbName = mem3:dbname(ShardDbName),
-    gen_server:cast(?MODULE, {evict, DbName});
-evictor({deleted, ShardDbName}) ->
-    DbName = mem3:dbname(ShardDbName),
-    gen_server:cast(?MODULE, {evict, DbName});
-evictor(_) ->
-    ok.
+handle_db_event(ShardDbName, created, St) ->
+    gen_server:cast(?MODULE, {evict, mem3:dbname(ShardDbName)}),
+    {ok, St};
+handle_db_event(ShardDbName, deleted, St) ->
+    gen_server:cast(?MODULE, {evict, mem3:dbname(ShardDbName)}),
+    {ok, St};
+handle_db_event(_DbName, _Event, St) ->
+    {ok, St}.
 
 
 open_ddoc({DbName, validation_funs}=Key) ->


Mime
View raw message