Sha256: 066ea5cfc8f5cf8795cac0fcf95de93543f7f973d9e6c01bc1415b5aa923e6c8

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

module MultiWorker
  module Adapters
    class Sneakers
      def self.configure(base, opts={})
        require 'json'

        base.class_eval do
          include ::Sneakers::Worker
          from_queue opts[:queue], opts.fetch(:adapter_opts, {})

          def work(msg)
            args = JSON.parse(msg)
            perform(*args)
          end

          def self.perform(*args)
            self.new.perform(*args)
          end

          def self.perform_async(*args)
            ::Sneakers.publish(args.to_json, :to_queue => @queue)
          end

          def perform_async(*args)
            self.class.perform_async(*args)
            #@queue.exchange.publish(args.to_json, :to_queue => @queue)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_worker-0.1.0 lib/multi_worker/adapters/sneakers.rb