configurable limits for ConcurrentLimiter

Pleroma.Web.RichMedia.Helpers & Pleroma.Web.MediaProxy
This commit is contained in:
Alexander Strizhakov 2021-01-09 18:52:40 +03:00
commit b4ff63d020
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
4 changed files with 75 additions and 1 deletions

View file

@ -297,7 +297,16 @@ defmodule Pleroma.Application do
@spec limiters_setup() :: :ok
def limiters_setup do
config = Config.get(ConcurrentLimiter, [])
[Pleroma.Web.RichMedia.Helpers, Pleroma.Web.MediaProxy]
|> Enum.each(&ConcurrentLimiter.new(&1, 1, 0))
|> Enum.each(fn module ->
mod_config = Keyword.get(config, module, [])
max_running = Keyword.get(mod_config, :max_running, 5)
max_waiting = Keyword.get(mod_config, :max_waiting, 5)
ConcurrentLimiter.new(module, max_running, max_waiting)
end)
end
end