You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ii...@apache.org on 2016/08/23 22:04:12 UTC

[1/2] couchdb-global-changes git commit: Update handle_config_terminate API

Repository: couchdb-global-changes
Updated Branches:
  refs/heads/master 203fb088e -> f7e43f56b


Update handle_config_terminate API

COUCHDB-3102


Project: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/commit/e7b6fd9e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/tree/e7b6fd9e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/diff/e7b6fd9e

Branch: refs/heads/master
Commit: e7b6fd9eddb2c2d3dc0dde0398d8f6455b39ceaa
Parents: 203fb08
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Wed Aug 17 11:55:59 2016 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Tue Aug 23 12:27:00 2016 -0700

----------------------------------------------------------------------
 src/global_changes_config_listener.erl | 71 -----------------------------
 src/global_changes_sup.erl             | 48 ++++++++++++++++++-
 2 files changed, 47 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/e7b6fd9e/src/global_changes_config_listener.erl
----------------------------------------------------------------------
diff --git a/src/global_changes_config_listener.erl b/src/global_changes_config_listener.erl
deleted file mode 100644
index 184177d..0000000
--- a/src/global_changes_config_listener.erl
+++ /dev/null
@@ -1,71 +0,0 @@
-% Licensed under the Apache License, Version 2.0 (the "License"); you may not
-% use this file except in compliance with the License. You may obtain a copy of
-% the License at
-%
-% http://www.apache.org/licenses/LICENSE-2.0
-%
-% Unless required by applicable law or agreed to in writing, software
-% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-% License for the specific language governing permissions and limitations under
-% the License.
-
--module(global_changes_config_listener).
-
--vsn(2).
--behavior(config_listener).
-
-
--export([
-    subscribe/0
-]).
-
--export([
-    handle_config_change/5,
-    handle_config_terminate/3
-]).
-
-
--define(LISTENER, global_changes_listener).
--define(SERVER, global_changes_server).
-
-subscribe() ->
-    config:listen_for_changes(?MODULE, nil).
-
-handle_config_change("global_changes", "max_event_delay", MaxDelayStr, _, _) ->
-    try list_to_integer(MaxDelayStr) of
-        MaxDelay ->
-            gen_server:cast(?LISTENER, {set_max_event_delay, MaxDelay})
-    catch error:badarg ->
-        ok
-    end,
-    {ok, nil};
-
-handle_config_change("global_changes", "max_write_delay", MaxDelayStr, _, _) ->
-    try list_to_integer(MaxDelayStr) of
-        MaxDelay ->
-            gen_server:cast(?SERVER, {set_max_write_delay, MaxDelay})
-    catch error:badarg ->
-        ok
-    end,
-    {ok, nil};
-
-handle_config_change("global_changes", "update_db", "false", _, _) ->
-    gen_server:cast(?LISTENER, {set_update_db, false}),
-    gen_server:cast(?SERVER, {set_update_db, false}),
-    {ok, nil};
-
-handle_config_change("global_changes", "update_db", _, _, _) ->
-    gen_server:cast(?LISTENER, {set_update_db, true}),
-    gen_server:cast(?SERVER, {set_update_db, true}),
-    {ok, nil};
-
-handle_config_change(_, _, _, _, _) ->
-    {ok, nil}.
-
-handle_config_terminate(_, stop, _) -> ok;
-handle_config_terminate(_, _, _) ->
-    spawn(fun() ->
-        timer:sleep(5000),
-        config:listen_for_changes(?MODULE, nil)
-    end).

http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/e7b6fd9e/src/global_changes_sup.erl
----------------------------------------------------------------------
diff --git a/src/global_changes_sup.erl b/src/global_changes_sup.erl
index 13394ea..ff3b2e9 100644
--- a/src/global_changes_sup.erl
+++ b/src/global_changes_sup.erl
@@ -18,16 +18,28 @@
 
 -export([init/1]).
 
+-export([handle_config_change/5]).
+-export([handle_config_terminate/3]).
+
+-define(LISTENER, global_changes_listener).
+-define(SERVER, global_changes_server).
 
 start_link() ->
     supervisor:start_link({local, ?MODULE}, ?MODULE, []).
 
 
 init([]) ->
-    global_changes_config_listener:subscribe(),
     {ok, {
         {one_for_one, 5, 10}, couch_epi:register_service(global_changes_epi, [
             {
+                config_listener_mon,
+                {config_listener_mon, start_link, [?MODULE, nil]},
+                permanent,
+                5000,
+                worker,
+                [config_listener_mon]
+            },
+            {
                 global_changes_server,
                 {global_changes_server, start_link, []},
                 permanent,
@@ -36,3 +48,37 @@ init([]) ->
                 [global_changes_server]
             }
     ])}}.
+
+handle_config_change("global_changes", "max_event_delay", MaxDelayStr, _, _) ->
+    try list_to_integer(MaxDelayStr) of
+        MaxDelay ->
+            gen_server:cast(?LISTENER, {set_max_event_delay, MaxDelay})
+    catch error:badarg ->
+        ok
+    end,
+    ok;
+
+handle_config_change("global_changes", "max_write_delay", MaxDelayStr, _, _) ->
+    try list_to_integer(MaxDelayStr) of
+        MaxDelay ->
+            gen_server:cast(?SERVER, {set_max_write_delay, MaxDelay})
+    catch error:badarg ->
+        ok
+    end,
+    ok;
+
+handle_config_change("global_changes", "update_db", "false", _, _) ->
+    gen_server:cast(?LISTENER, {set_update_db, false}),
+    gen_server:cast(?SERVER, {set_update_db, false}),
+    ok;
+
+handle_config_change("global_changes", "update_db", _, _, _) ->
+    gen_server:cast(?LISTENER, {set_update_db, true}),
+    gen_server:cast(?SERVER, {set_update_db, true}),
+    ok;
+
+handle_config_change(_, _, _, _, _) ->
+    ok.
+
+handle_config_terminate(_Server, _Reason, _State) ->
+    ok.


[2/2] couchdb-global-changes git commit: Merge remote branch 'cloudant:3102-fix-config_subscription'

Posted by ii...@apache.org.
Merge remote branch 'cloudant:3102-fix-config_subscription'

This closes #15

Signed-off-by: ILYA Khlopotov <ii...@ca.ibm.com>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/commit/f7e43f56
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/tree/f7e43f56
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/diff/f7e43f56

Branch: refs/heads/master
Commit: f7e43f56ba239f08a3368ff4aea88e50132b7952
Parents: 203fb08 e7b6fd9
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Tue Aug 23 14:59:45 2016 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Tue Aug 23 14:59:45 2016 -0700

----------------------------------------------------------------------
 src/global_changes_config_listener.erl | 71 -----------------------------
 src/global_changes_sup.erl             | 48 ++++++++++++++++++-
 2 files changed, 47 insertions(+), 72 deletions(-)
----------------------------------------------------------------------