couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [1/3] chttpd commit: updated refs/heads/master to ddd63ee
Date Thu, 01 Oct 2015 15:05:57 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 68a028995 -> ddd63eefa


Update to new couch_epi API


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

Branch: refs/heads/master
Commit: faca4ca1e6c72d631a01b07721f529ae1e428c78
Parents: 64a5728
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Mon Sep 28 09:47:02 2015 -0700
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Mon Sep 28 09:47:02 2015 -0700

----------------------------------------------------------------------
 src/chttpd_epi.erl | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/chttpd_sup.erl | 23 +++++++++------------
 2 files changed, 63 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/faca4ca1/src/chttpd_epi.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_epi.erl b/src/chttpd_epi.erl
new file mode 100644
index 0000000..ffbd87a
--- /dev/null
+++ b/src/chttpd_epi.erl
@@ -0,0 +1,54 @@
+% 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(chttpd_epi).
+
+-behaviour(couch_epi_plugin).
+
+-export([
+    app/0,
+    providers/0,
+    services/0,
+    data_subscriptions/0,
+    data_providers/0,
+    processes/0,
+    notify/3
+]).
+
+app() ->
+    chttpd.
+
+providers() ->
+    [
+        {chttpd_handlers, chttpd_httpd_handlers}
+    ].
+
+
+services() ->
+    [
+        {chttpd_auth, chttpd_auth},
+        {chttpd_handlers, chttpd_handlers},
+        {chttpd, chttpd_plugin}
+    ].
+
+data_subscriptions() ->
+    [].
+
+data_providers() ->
+    [].
+
+processes() ->
+    [].
+
+notify(_Key, _Old, _New) ->
+    ok.

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/faca4ca1/src/chttpd_sup.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_sup.erl b/src/chttpd_sup.erl
index 00c4588..64a5080 100644
--- a/src/chttpd_sup.erl
+++ b/src/chttpd_sup.erl
@@ -18,20 +18,17 @@
 
 %% Helper macro for declaring children of supervisor
 -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 100, Type, [I]}).
+-define(NAMED_CHILD(I, M, Type), {I, {M, start_link, []}, permanent, 100, Type, [M]}).
 
 start_link(Args) ->
     supervisor:start_link({local,?MODULE}, ?MODULE, Args).
 
 init([]) ->
-    couch_epi:register_service(chttpd_auth),
-    couch_epi:register_service(chttpd_handlers),
-    couch_epi:register_service(chttpd),
-
     chttpd_config_listener:subscribe(),
-    {ok, {{one_for_one, 3, 10}, [
+    ServiceProcesses = couch_epi:register_service(chttpd_epi),
+
+    {ok, {{one_for_one, 3, 10}, add_auth_cache_if_missing(ServiceProcesses) ++ [
         ?CHILD(chttpd, worker),
-        ?CHILD(auth_cache_handler(), worker),
-        chttpd_handlers:provider(chttpd, chttpd_httpd_handlers),
         {chttpd_auth_cache_lru,
 	 {ets_lru, start_link, [chttpd_auth_cache_lru, lru_opts()]},
 	 permanent, 5000, worker, [ets_lru]}
@@ -57,10 +54,8 @@ lru_opts() ->
             []
     end.
 
-auth_cache_handler() ->
-    case application:get_env(chttpd, auth_cache) of
-        {ok, Module} ->
-            Module;
-        _ ->
-            chttpd_auth_cache
-    end.
+add_auth_cache_if_missing(Children) ->
+    case lists:keymember(auth_cache, 1, Children) of
+        true -> Children;
+        false -> [?NAMED_CHILD(auth_cache, chttpd_auth_cache, worker)]
+     end.


Mime
View raw message