From 4e26b3679e9743690a85c9f72f7f4fc8ea8fd3f0 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Thu, 11 Jun 2015 16:38:30 +0200 Subject: Implement rate limiting of add_chain --- src/catlfish_sup.erl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/catlfish_sup.erl') 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]}}. -- cgit v1.1