Sha256: c86b3ff0b965e1a0587d506449db95e38398508191e3bcef790f074d4e08a377

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

module MultiWorker
  module Adapters
    class Toro
      def self.configure(base, opts={})
        base.class_eval do
          include ::Toro::Worker

          @queue = opts[:queue]
          @toro_options = {queue: @queue}

          if opts.has_key?(:retry)
            @retry = opts[:retry]
            case @retry
              when Hash
                @toro_options.merge!(retry_interval: @retry[:delay])
              when Fixnum, ActiveSupport::Duration
                @toro_options.merge!(retry_interval: @retry)
            end
          end

          toro_options @toro_options

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

          def perform_async(*args)
            self.class.perform_async(*args)
          end
        end
      end

      def self.rake_task
        require 'rake'
        require 'toro'
        require 'tasks/tasks'
        ::Rake::Task["toro"]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_worker-0.2.0 lib/multi_worker/adapters/toro.rb