aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/http/adapter_helper
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-05-17 22:16:02 +0300
committerrinpatch <rinpatch@sdf.org>2020-07-15 15:26:35 +0300
commit4128e3a84a2b6d75a8f92759e65ee673b47cec01 (patch)
treeb2202efe95dbb008bdbfda6e879bacaf7c116d0d /lib/pleroma/http/adapter_helper
parent94c8f3cfafb92c6d092549b24bb69f3870e1c0d8 (diff)
downloadpleroma-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.ex21
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