Sha256: 457cb46a1712cf99de47b5026fd1f4412c91d537c0cbc9c99f30a93a9234a51c
Contents?: true
Size: 968 Bytes
Versions: 3
Compression:
Stored size: 968 Bytes
Contents
# frozen_string_literal: true require "active_job" require "json" require "super_spreader/scheduler_config" require "super_spreader/spreader" require "super_spreader/stop_signal" module SuperSpreader class SchedulerJob < ActiveJob::Base extend StopSignal def perform return if self.class.stopped? log(started_at: Time.current.iso8601) log(config.serializable_hash) super_spreader = Spreader.new(*config.super_spreader_config) next_id = super_spreader.enqueue_spread(**config.spread_options) log(next_id: next_id) return if next_id.zero? self.class.set(wait_until: next_run_at).perform_later log(next_run_at: next_run_at.iso8601) end def next_run_at config.duration.seconds.from_now end def config @config ||= SchedulerConfig.new end private def log(hash) SuperSpreader.logger.info({subject: self.class.name}.merge(hash).to_json) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
super_spreader-0.2.1 | lib/super_spreader/scheduler_job.rb |
super_spreader-0.2.0 | lib/super_spreader/scheduler_job.rb |
super_spreader-0.1.0.beta2 | lib/super_spreader/scheduler_job.rb |