5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 08:36:22 +00:00

Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl

This commit is contained in:
Sutty 2024-03-25 16:33:13 +00:00
commit 9fc0ae9c16
2 changed files with 14 additions and 1 deletions

View file

@ -49,7 +49,9 @@ module Api
# #
# @param initial_state [Symbol] # @param initial_state [Symbol]
def process!(initial_state) 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 end
end end

View file

@ -4,6 +4,17 @@
class ApplicationJob < ActiveJob::Base class ApplicationJob < ActiveJob::Base
include Que::ActiveJob::JobExtensions 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 private
def site def site