couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [1/3] couch commit: updated refs/heads/master to 4ca9e41
Date Thu, 01 Oct 2015 15:06:56 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master 0430a7fb1 -> 4ca9e4184


Update to new couch_epi API


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

Branch: refs/heads/master
Commit: a27ce338ee26ee3f294d32f225de20c56a76409d
Parents: 9afa6a0
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Mon Sep 28 09:39:26 2015 -0700
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Mon Sep 28 09:43:53 2015 -0700

----------------------------------------------------------------------
 src/couch_db_epi.erl           | 51 +++++++++++++++++++++++++++++++++++++
 src/couch_secondary_sup.erl    |  7 ++---
 src/test_util.erl              |  4 +--
 test/couch_db_plugin_tests.erl | 48 ++++++++++++++++++++++++++--------
 4 files changed, 93 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/a27ce338/src/couch_db_epi.erl
----------------------------------------------------------------------
diff --git a/src/couch_db_epi.erl b/src/couch_db_epi.erl
new file mode 100644
index 0000000..5ff8cfc
--- /dev/null
+++ b/src/couch_db_epi.erl
@@ -0,0 +1,51 @@
+% 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(couch_db_epi).
+
+-behaviour(couch_epi_plugin).
+
+-export([
+    app/0,
+    providers/0,
+    services/0,
+    data_subscriptions/0,
+    data_providers/0,
+    processes/0,
+    notify/3
+]).
+
+app() ->
+    couch.
+
+providers() ->
+    [
+        {chttpd_handlers, couch_httpd_handlers}
+    ].
+
+
+services() ->
+    [
+        {couch_db, couch_db_plugin}
+    ].
+
+data_subscriptions() ->
+    [].
+
+data_providers() ->
+    [].
+
+processes() ->
+    [].
+
+notify(_Key, _Old, _New) ->
+    ok.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/a27ce338/src/couch_secondary_sup.erl
----------------------------------------------------------------------
diff --git a/src/couch_secondary_sup.erl b/src/couch_secondary_sup.erl
index 0f62575..1aeb303 100644
--- a/src/couch_secondary_sup.erl
+++ b/src/couch_secondary_sup.erl
@@ -18,7 +18,6 @@ start_link() ->
     supervisor:start_link({local,couch_secondary_services}, ?MODULE, []).
 
 init([]) ->
-    couch_epi:register_service(couch_db),
     SecondarySupervisors = [
         {couch_plugin_event,
             {gen_event, start_link, [{local, couch_plugin}]},
@@ -27,10 +26,8 @@ init([]) ->
             worker,
             dynamic}
     ],
-    ServiceProviders = [
-        chttpd_handlers:provider(couch, couch_httpd_handlers)
-    ],
-    Children = SecondarySupervisors ++ ServiceProviders ++ [
+    ServiceProcesses = couch_epi:register_service(couch_db_epi),
+    Children = SecondarySupervisors ++ ServiceProcesses ++ [
         begin
             {ok, {Module, Fun, Args}} = couch_util:parse_term(SpecStr),
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/a27ce338/src/test_util.erl
----------------------------------------------------------------------
diff --git a/src/test_util.erl b/src/test_util.erl
index 6064b77..d13f850 100644
--- a/src/test_util.erl
+++ b/src/test_util.erl
@@ -70,7 +70,7 @@ start_couch(IniFiles, ExtraApps) ->
     ok = application:set_env(config, ini_files, IniFiles),
 
     Apps = start_applications(
-        [goldrush, lager, inets, ibrowse, ssl, config, couch_event, couch]
+        [goldrush, lager, inets, ibrowse, ssl, config, couch_epi, couch_event, couch]
         ++ ExtraApps),
 
     #test_context{started = Apps}.
@@ -222,7 +222,7 @@ start(Module, ExtraApps) ->
     start(Module, ExtraApps, []).
 
 start(Module, ExtraApps, Options) ->
-    Apps = start_applications([config, ioq|ExtraApps]),
+    Apps = start_applications([config, ioq, couch_epi | ExtraApps]),
     ToMock = [config, couch_stats] -- proplists:get_value(dont_mock, Options, []),
     mock(ToMock),
     #test_context{module = Module, mocked = ToMock, started = Apps}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/a27ce338/test/couch_db_plugin_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_db_plugin_tests.erl b/test/couch_db_plugin_tests.erl
index cd563b6..77d9529 100644
--- a/test/couch_db_plugin_tests.erl
+++ b/test/couch_db_plugin_tests.erl
@@ -21,23 +21,51 @@
     on_delete/2
 ]).
 
+-export([ %% couch_epi_plugin behaviour
+    app/0,
+    providers/0,
+    services/0,
+    data_providers/0,
+    data_subscriptions/0,
+    processes/0,
+    notify/3
+]).
+
 -include_lib("couch/include/couch_eunit.hrl").
 -include_lib("couch/include/couch_db.hrl").
 
 -record(ctx, {pid, handle}).
 
+%% couch_epi_plugin behaviour
+
+app() -> test_app.
+providers() -> [{couch_db, ?MODULE}].
+services() -> [].
+data_providers() -> [].
+data_subscriptions() -> [].
+processes() -> [].
+notify(_, _, _) -> ok.
+
+start_epi() ->
+    application:load(couch_epi),
+    Plugins = application:get_env(couch_epi, plugins, []),
+    ok = application:set_env(couch_epi, plugins, append_if_missing(Plugins, ?MODULE)),
+    ok = application:start(couch_epi).
+
+append_if_missing(List, Value) ->
+    case lists:member(Value, List) of
+        true -> List;
+        false -> [Value | List]
+    end.
+
 setup() ->
     error_logger:tty(false),
-    application:start(couch_epi),
-    {ok, FunctionsPid} = couch_epi_functions:start_link(
-        test_app, {epi_key, couch_db}, {modules, [?MODULE]},
-        [{interval, 100}]),
-    ok = couch_epi_functions:wait(FunctionsPid),
-    #ctx{pid = FunctionsPid, handle = couch_epi:get_handle(couch_db)}.
-
-teardown(#ctx{pid = FunctionsPid}) ->
-    erlang:unlink(FunctionsPid),
-    couch_epi_functions:stop(FunctionsPid),
+    start_epi(),
+    #ctx{handle = couch_epi:get_handle(couch_db)}.
+
+teardown(#ctx{}) ->
+    Plugins = application:get_env(couch_epi, plugins, []),
+    application:set_env(couch_epi, plugins, Plugins -- [?MODULE]),
     application:stop(couch_epi),
     ok.
 


Mime
View raw message