Class: SidekiqRobustJob::MissedJobsScheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_robust_job/missed_jobs_scheduler.rb

Instance Method Summary collapse

Constructor Details

#initialize(cron:, scheduled_jobs_repository:, job_class:) ⇒ MissedJobsScheduler

Returns a new instance of MissedJobsScheduler.



6
7
8
9
# File 'lib/sidekiq_robust_job/missed_jobs_scheduler.rb', line 6

def initialize(cron:, scheduled_jobs_repository:, job_class:)
  @serializer = MissedJobSerializer.new(cron, job_class)
  @scheduled_jobs_repository = scheduled_jobs_repository
end

Instance Method Details

#scheduleObject



11
12
13
14
15
16
17
18
19
# File 'lib/sidekiq_robust_job/missed_jobs_scheduler.rb', line 11

def schedule
  scheduled_jobs_repository.new(serializer.serialize).tap do |job|
    if job.valid?
      job.save
    else
      raise_invalid_job(job)
    end
  end
end