You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
# app/jobs/daily_dump_job.rb
|
|
class DailyDumpJob < ApplicationJob
|
|
queue_as :daily_dump
|
|
include GoodJob::ActiveJobExtensions::Concurrency
|
|
|
|
good_job_control_concurrency_with(
|
|
# Maximum number of unfinished jobs to allow with the concurrency key
|
|
total_limit: 1,
|
|
|
|
# Or, if more control is needed:
|
|
# Maximum number of jobs with the concurrency key to be
|
|
# concurrently enqueued (excludes performing jobs)
|
|
enqueue_limit: 1,
|
|
|
|
# Maximum number of jobs with the concurrency key to be
|
|
# concurrently performed (excludes enqueued jobs)
|
|
perform_limit: 1,
|
|
|
|
# Note: Under heavy load, the total number of jobs may exceed the
|
|
# sum of `enqueue_limit` and `perform_limit` because of race conditions
|
|
# caused by imperfectly disjunctive states. If you need to constrain
|
|
# the total number of jobs, use `total_limit` instead. See #378.
|
|
|
|
# A unique key to be globally locked against.
|
|
# Can be String or Lambda/Proc that is invoked in the context of the job.
|
|
# Note: Arguments passed to #perform_later must be accessed through `arguments` method.
|
|
key: -> { "Unique-DailyDumpJob" }
|
|
)
|
|
|
|
def perform
|
|
zip_path = DumpService.perform
|
|
if zip_path
|
|
DumpMailer.daily_dump(zip_path).deliver_now
|
|
File.delete(zip_path) if File.exist?(zip_path)
|
|
else
|
|
Rails.logger.error "[DailyDumpJob] Dump fehlgeschlagen."
|
|
end
|
|
end
|
|
end
|