Sha256: e4ed364c1b5569119b3e59d7a81801bb3bd51793565b7f16f6486601cf6bd706

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 Bytes

Contents

# frozen_string_literal: true

require "sidekiq"
require "timeout"

module Miteru
  module Jobs
    class CrawleJob
      include Sidekiq::Job
      include Concerns::DatabaseConnectable

      #
      # @param [String] url
      # @param [String] source
      #
      def perform(url, source)
        website = Miteru::Website.new(url, source:)

        with_db_connection do
          Timeout.timeout(Miteru.config.sidekiq_job_timeout) do
            result = Crawler.result(website)
            if result.success?
              Miteru.logger.info("Crawler:#{website.truncated_url} succeeded.")
            else
              Miteru.logger.info("Crawler:#{website.truncated_url} failed - #{result.failure}.")
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miteru-3.0.0 lib/miteru/sidekiq/jobs.rb
miteru-2.4.0 lib/miteru/sidekiq/jobs.rb