diff options
author | rinpatch <rinpatch@sdf.org> | 2020-05-17 22:16:02 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-07-15 15:26:35 +0300 |
commit | 4128e3a84a2b6d75a8f92759e65ee673b47cec01 (patch) | |
tree | b2202efe95dbb008bdbfda6e879bacaf7c116d0d /lib/pleroma/http/adapter_helper | |
parent | 94c8f3cfafb92c6d092549b24bb69f3870e1c0d8 (diff) | |
download | pleroma-4128e3a84a2b6d75a8f92759e65ee673b47cec01.tar.gz |
HTTP: Implement max request limits
Diffstat (limited to 'lib/pleroma/http/adapter_helper')
-rw-r--r-- | lib/pleroma/http/adapter_helper/gun.ex | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/pleroma/http/adapter_helper/gun.ex b/lib/pleroma/http/adapter_helper/gun.ex index 5b4629978..883f7f6f7 100644 --- a/lib/pleroma/http/adapter_helper/gun.ex +++ b/lib/pleroma/http/adapter_helper/gun.ex @@ -49,4 +49,25 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun do err -> err end end + + @prefix Pleroma.Gun.ConnectionPool + def limiter_setup do + wait = Pleroma.Config.get([:connections_pool, :connection_acquisition_wait]) + retries = Pleroma.Config.get([:connections_pool, :connection_acquisition_retries]) + + :pools + |> Pleroma.Config.get([]) + |> Enum.each(fn {name, opts} -> + max_running = Keyword.get(opts, :size, 50) + max_waiting = Keyword.get(opts, :max_waiting, 10) + + :ok = + ConcurrentLimiter.new(:"#{@prefix}.#{name}", max_running, max_waiting, + wait: wait, + max_retries: retries + ) + end) + + :ok + end end |