summaryrefslogtreecommitdiff
path: root/src/catlfish_sup.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-06-11 16:38:30 +0200
committerLinus Nordberg <linus@nordu.net>2015-06-12 15:45:18 +0200
commit4e26b3679e9743690a85c9f72f7f4fc8ea8fd3f0 (patch)
tree6c445bb8644a7f2ece4084b731faedb726aea3f0 /src/catlfish_sup.erl
parent3de0e0af3521f826e60468b2d6d19717fa0a53d7 (diff)
Implement rate limiting of add_chain
Diffstat (limited to 'src/catlfish_sup.erl')
-rw-r--r--src/catlfish_sup.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/catlfish_sup.erl b/src/catlfish_sup.erl
index 5da7b93..353b691 100644
--- a/src/catlfish_sup.erl
+++ b/src/catlfish_sup.erl
@@ -9,6 +9,16 @@
start_link(_Args) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+permanent_worker(Name, {Module, Function, Args}) ->
+ permanent_worker(Name, {Module, Function, Args}, [Module]).
+
+permanent_worker(Name, StartFunc, Modules) ->
+ {Name,
+ StartFunc,
+ permanent,
+ 10000,
+ worker, Modules}.
+
gen_http_config(Config, SSLOptions, SSLFlag) ->
{ChildName, IpAddress, Port, Module} = Config,
{ok, IPv4Address} =
@@ -37,6 +47,7 @@ init([]) ->
gen_http_config(Config, SSLOptions, false)
end, application:get_env(catlfish, http_servers, [])),
lager:debug("Starting servers ~p", [Servers]),
+ RateLimit = permanent_worker(ratelimit, {ratelimit, start_link, []}),
{ok,
{{one_for_one, 3, 10},
- Servers}}.
+ [RateLimit | Servers]}}.