Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

# How long a finished job row stays (see clear_finished_jobs in
# config/recurring.yml). The row holds the job arguments.
config.solid_queue.clear_finished_jobs_after = 1.day

end
end

Expand Down
10 changes: 10 additions & 0 deletions config/recurring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,13 @@ expire_identity_governance_proposals:
sweep_pending_shares:
class: SweepPendingSharesJob
schedule: every minute

# Delete the rows of finished jobs after one day
# (config.solid_queue.clear_finished_jobs_after). A finished row keeps the job
# arguments, and for a magic link or a guardian consent email that includes
# the raw link token. /admin/jobs shows finished jobs only for that day, and
# the last run of a recurring task goes with its job row. A failed job is not
# finished: it stays until a person retries or discards it.
clear_finished_jobs:
command: "SolidQueue::Job.clear_finished_in_batches(sleep_between_batches: 0.3)"
schedule: every hour at minute 12
35 changes: 35 additions & 0 deletions spec/config/recurring_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require "rails_helper"
require "fugit"

# Solid Queue reads config/recurring.yml only when the worker starts. An entry
# with a typing error stops the worker, drops the task, or fails each time it
# runs, and no other spec sees it.
RSpec.describe "config/recurring.yml" do # rubocop:disable RSpec/DescribeClass
known_keys = %w[class command args schedule queue priority description]

YAML.load_file(Rails.root.join("config/recurring.yml")).each do |key, options|
describe key do
it "has a schedule that Solid Queue can read" do
expect(Fugit.parse(options["schedule"], multi: :fail)).to be_a(Fugit::Cron)
end

it "uses only the keys that Solid Queue reads" do
expect(options.keys - known_keys).to be_empty
end

if options["class"]
it "names a job class that exists" do
expect(options["class"].safe_constantize).to be < ActiveJob::Base
end
else
it "calls a method that exists" do
receiver, method = options.fetch("command").match(/\A([\w:]+)\.(\w+)/).captures

expect(receiver.constantize).to respond_to(method)
end
end
end
end
end
Loading