Sha256: 6d49a293dd4e146b83923673110422f7dff001bd18313cb21e3fa7686ca5a156
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module Wayfarer class Base < ActiveJob::Base include Wayfarer::Middleware::Worker extend Forwardable after_enqueue do |_job| task.counter.increment end after_perform { |job| GC.new(job).run } rescue_from(StandardError) { GC.new(self).run } def self.retry_on(*argv) super(*argv) do |job, error| job.task.barrier.seen?(job.task.url) GC.new(job).run yield job, error if block_given? end end def self.discard_on(*argv) super(*argv) do |job, error| job.task.barrier.seen?(job.task.url) GC.new(job).run yield job, error if block_given? end end def self.crawl_later(url, batch: SecureRandom.uuid) perform_later(Task.new(url, batch)) end def retry_job(...) super(...) # increments the counter by re-enqueuing the job task.counter.decrement end def perform(task) task.job = self chain.call(task) end def task arguments.first end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.3 | lib/wayfarer/base.rb |
wayfarer-0.4.2 | lib/wayfarer/base.rb |
wayfarer-0.4.1 | lib/wayfarer/base.rb |