5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:46:21 +00:00

fix: espaciar el procesamiento de tareas

closes #15621

closes #15622

closes #15623

closes #15729

closes #15730

closes #15731

closes #15735

closes #15736

closes #15824
This commit is contained in:
f 2024-03-25 13:32:08 -03:00
parent 366494b615
commit d7de351e1a
No known key found for this signature in database
2 changed files with 14 additions and 1 deletions

View file

@ -49,7 +49,9 @@ module Api
#
# @param initial_state [Symbol]
def process!(initial_state)
::ActivityPub::ProcessJob.perform_later(site: site, body: request.raw_post, initial_state: initial_state)
::ActivityPub::ProcessJob
.set(wait: ApplicationJob.random_wait)
.perform_later(site: site, body: request.raw_post, initial_state: initial_state)
end
end
end

View file

@ -4,6 +4,17 @@
class ApplicationJob < ActiveJob::Base
include Que::ActiveJob::JobExtensions
# Esperar una cantidad random de segundos primos, para que no se
# superpongan tareas
#
# @return [Array<ActiveSupport::Duration>]
RANDOM_WAIT = [3, 5, 7, 11, 13].seconds
# @return [ActiveSupport::Duration]
def self.random_wait
RANDOM_WAIT.sample
end
private
def site