mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 20:16:23 +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:
parent
366494b615
commit
d7de351e1a
2 changed files with 14 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue