Sha256: 6a2e542440a2ce5ad7bfbd5a9aaeb6be92a00241ead056abf615afd6108c1c64

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

# frozen_string_literal: true

require 'lazy_resque/store'
require 'lazy_resque/lazy_enqueue'

module LazyResque
  # Extensions to append to the main Resque module to add
  # Resque.lazy_enqueue and Resque.process_lazy_enqueues
  module ResqueExtensions
    def lazy_enqueue(klass, *args)
      LazyResque::Store.queue_up(LazyResque::LazyEnqueue.new(klass, *args))
    end

    def process_lazy_enqueues
      current_queue = LazyResque::Store.queue
      return if current_queue.empty?
      Thread.new(current_queue) do |jobs_to_be_enqueued|
        jobs_to_be_enqueued.each(&:enqueue)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lazy_resque-0.0.1 lib/lazy_resque/resque_extensions.rb