Sha256: e996ad2e07fdb9a9a9c4168b619f85dba850e7d9404474a6e74c25f0adea7e0d

Contents?: true

Size: 1.91 KB

Versions: 59

Compression:

Stored size: 1.91 KB

Contents

module Resque
  # The Failure module provides an interface for working with different
  # failure backends.
  #
  # You can use it to query the failure backend without knowing which specific
  # backend is being used. For instance, the Resque web app uses it to display
  # stats and other information.
  module Failure
    # Creates a new failure, which is delegated to the appropriate backend.
    #
    # Expects a hash with the following keys:
    #   :exception - The Exception object
    #   :worker    - The Worker object who is reporting the failure
    #   :queue     - The string name of the queue from which the job was pulled
    #   :payload   - The job's payload
    def self.create(options = {})
      backend.new(*options.values_at(:exception, :worker, :queue, :payload)).save
    end

    #
    # Sets the current backend. Expects a class descendent of
    # `Resque::Failure::Base`.
    #
    # Example use:
    #   require 'resque/failure/hoptoad'
    #   Resque::Failure.backend = Resque::Failure::Hoptoad
    def self.backend=(backend)
      @backend = backend
    end

    # Returns the current backend class. If none has been set, falls
    # back to `Resque::Failure::Redis`
    def self.backend
      return @backend if @backend
      require 'resque/failure/mongo'
      @backend = Failure::Mongo
    end

    # Returns the int count of how many failures we have seen.
    def self.count
      backend.count
    end

    # Returns an array of all the failures, paginated.
    #
    # `start` is the int of the first item in the page, `count` is the
    # number of items to return.
    def self.all(start = 0, count = 1)
      backend.all(start, count)
    end

    # The string url of the backend's web interface, if any.
    def self.url
      backend.url
    end
    
    # Clear all failure jobs
    def self.clear
      backend.clear
    end
    
    def self.requeue(index)
      backend.requeue(index)
    end
  end
end

Version data entries

59 entries across 59 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.7.4 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.7.3 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.7.2 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.7.1 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.7.0 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.9 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.8 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.7 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.6 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.5 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.4 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.3 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.2 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.1 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.6.0 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.5.17 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.5.16 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.5.15 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb
classiccms-0.5.14 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure.rb