mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 04:56:22 +00:00
Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
9fc0ae9c16
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