gearheads
/
mastodon
Archived
2
0
Fork 0

Change `ActivityPub::DeliveryWorker` retries to be spread out more (#21956)

gh/stable
Claire 2023-03-03 21:08:22 +01:00
parent 2a37dc7967
commit 6962d117b7
1 changed files with 10 additions and 0 deletions

View File

@ -10,6 +10,16 @@ class ActivityPub::DeliveryWorker
sidekiq_options queue: 'push', retry: 16, dead: false
# Unfortunately, we cannot control Sidekiq's jitter, so add our own
sidekiq_retry_in do |count|
# This is Sidekiq's default delay
delay = (count**4) + 15
# Our custom jitter, that will be added to Sidekiq's built-in one.
# Sidekiq's built-in jitter is `rand(10) * (count + 1)`
jitter = rand(0.5 * (count**4))
delay + jitter
end
HEADERS = { 'Content-Type' => 'application/activity+json' }.freeze
def perform(json, source_account_id, inbox_url, options = {})