From 9b73c35ca8b051316815461247b802bc8567854f Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 30 Jun 2020 18:35:15 +0300 Subject: [PATCH] Request limiter setup: consider {:error, :existing} a success When the application restarts (which happens after certain config changes), the limiters are not destroyed, so `ConcurrentLimiter.new` will produce {:error, :existing} --- lib/pleroma/http/adapter_helper/gun.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/http/adapter_helper/gun.ex b/lib/pleroma/http/adapter_helper/gun.ex index 07aaed7f6..b8c4cc59c 100644 --- a/lib/pleroma/http/adapter_helper/gun.ex +++ b/lib/pleroma/http/adapter_helper/gun.ex @@ -88,11 +88,17 @@ def limiter_setup do max_running = Keyword.get(opts, :size, 50) max_waiting = Keyword.get(opts, :max_waiting, 10) - :ok = + result = ConcurrentLimiter.new(:"#{@prefix}.#{name}", max_running, max_waiting, wait: wait, max_retries: retries ) + + case result do + :ok -> :ok + {:error, :existing} -> :ok + e -> raise e + end end) :ok