Sha256: 879a91329f4c76c40ad0e86086faee61f1a76a347f52501e6a4516bbeeec6cbc

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module JobIteration
  class LogSubscriber < ActiveSupport::LogSubscriber
    def logger
      JobIteration.logger
    end

    def nil_enumerator(event)
      info do
        "[JobIteration::Iteration] `build_enumerator` returned nil. Skipping the job."
      end
    end

    def not_found(event)
      info do
        "[JobIteration::Iteration] Enumerator found nothing to iterate! " \
          "times_interrupted=#{event.payload[:times_interrupted]} cursor_position=#{event.payload[:cursor_position]}"
      end
    end

    def interrupted(event)
      info do
        "[JobIteration::Iteration] Interrupting and re-enqueueing the job " \
          "cursor_position=#{event.payload[:cursor_position]}"
      end
    end

    def completed(event)
      info do
        message = "[JobIteration::Iteration] Completed iterating. times_interrupted=%d total_time=%.3f"
        Kernel.format(message, event.payload[:times_interrupted], event.payload[:total_time])
      end
    end
  end
end

JobIteration::LogSubscriber.attach_to(:iteration)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
job-iteration-1.7.0 lib/job-iteration/log_subscriber.rb
job-iteration-1.6.0 lib/job-iteration/log_subscriber.rb
job-iteration-1.5.1 lib/job-iteration/log_subscriber.rb
job-iteration-1.5.0 lib/job-iteration/log_subscriber.rb
job-iteration-1.4.1 lib/job-iteration/log_subscriber.rb
job-iteration-1.4.0 lib/job-iteration/log_subscriber.rb