Sha256: ca7923e2006505ad04de3304457bdd3614cc9e4cbe99701fbcab70483faa5756

Contents?: true

Size: 751 Bytes

Versions: 9

Compression:

Stored size: 751 Bytes

Contents

require 'active_support/core_ext/marshal'

# Borrowed from:
# https://github.com/jeremy/resque-rails/blob/master/lib/resque/rails/queue.rb
module Sufia
  module Resque
    class Queue
      attr_reader :default_queue_name

      def initialize(default_queue_name)
        @default_queue_name = default_queue_name
      end

      def push(job)
        queue = job.respond_to?(:queue_name) ? job.queue_name : default_queue_name
        begin
          ::Resque.enqueue_to queue, MarshaledJob, Marshal.dump(job)
        rescue Redis::CannotConnectError
          logger.error "Redis is down!"
        end
      end
    end

    class MarshaledJob
      def self.perform(marshaled_job)
        Marshal.load(marshaled_job).run
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sufia-0.1.0 lib/sufia/queue/resque.rb
sufia-0.0.8 lib/sufia/queue/resque.rb
sufia-0.0.7 lib/sufia/queue/resque.rb
sufia-0.0.6 lib/sufia/queue/resque.rb
sufia-0.0.5 lib/sufia/queue/resque.rb
sufia-0.0.4 lib/sufia/queue/resque.rb
sufia-0.0.3 lib/sufia/queue/resque.rb
sufia-0.0.2 lib/sufia/queue/resque.rb
sufia-0.0.1 lib/sufia/queue/resque.rb