Sha256: 5b209280be054c480371341106b51ae707ae9a2b0876943fe378309157b016fc

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

require 'belated'

module ActiveJob # :nodoc:
  module QueueAdapters # :nodoc:
    # The adapter in charge of handling ActiveJob integration.
    # WIP
    class BelatedAdapter
      def instance
        @instance ||= Belated::Client.instance
      rescue StandardError
        @instance = Belated::Client.new
      end

      def enqueue(job) # :nodoc:
        Rails.logger.info "Belated got job #{job}"
        instance.perform(job, active_job: true)
      end

      def enqueue_at(job, timestamp) # :nodoc:
        Rails.logger.info "Belated got job #{job} to be performed at #{Time.at(timestamp)}"
        instance.perform_belated(job, at: timestamp, active_job: true)
      end

      # JobWrapper that overwrites perform for ActiveJob
      class JobWrapper < Belated::JobWrapper
        def perform
          Base.execute job.serialize
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
belated-0.9.0 lib/active_job/queue_adapters/belated_adapter.rb
belated-0.8.3 lib/active_job/queue_adapters/belated_adapter.rb
belated-0.8.2 lib/active_job/queue_adapters/belated_adapter.rb
belated-0.8.1 lib/active_job/queue_adapters/belated_adapter.rb
belated-0.8.0 lib/active_job/queue_adapters/belated_adapter.rb