diff options
author | rinpatch <rinpatch@sdf.org> | 2020-06-30 18:35:15 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-07-15 15:26:35 +0300 |
commit | 9b73c35ca8b051316815461247b802bc8567854f (patch) | |
tree | 6a860a9d9bc9abc8ed475e916f7872264e14965b | |
parent | 12fa5541f01ca5cfe082a62dac3317da78043e8f (diff) | |
download | pleroma-9b73c35ca8b051316815461247b802bc8567854f.tar.gz |
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}
-rw-r--r-- | lib/pleroma/http/adapter_helper/gun.ex | 8 |
1 files changed, 7 insertions, 1 deletions
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 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun 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 |