forked from AkkomaGang/akkoma
24 lines
600 B
Elixir
24 lines
600 B
Elixir
|
# Pleroma: A lightweight social networking server
|
||
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||
|
|
||
|
defmodule Pleroma.Workers.WorkerHelper do
|
||
|
alias Pleroma.Config
|
||
|
|
||
|
def worker_args(queue) do
|
||
|
case Config.get([:workers, :retries, queue]) do
|
||
|
nil -> []
|
||
|
max_attempts -> [max_attempts: max_attempts]
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def sidekiq_backoff(attempt, pow \\ 4, base_backoff \\ 15) do
|
||
|
backoff =
|
||
|
:math.pow(attempt, pow) +
|
||
|
base_backoff +
|
||
|
:rand.uniform(2 * base_backoff) * attempt
|
||
|
|
||
|
trunc(backoff)
|
||
|
end
|
||
|
end
|