Sha256: 41389acb7dfb14fdf9b46d67f5f7cc1859371c20910a2c784b318ac89260b08c

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require 'resque'

module Resque
  module FailureServer
    VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
    
    def self.registered(app)
      app.get '/failed/list' do
        @queues = Resque::Failure.backend.queues
        failures_view(:failures)
      end
      
      app.get '/failed/:queue' do
        @start = params[:start].to_i || 0
        @failed = Resque::Failure.backend.all(params[:queue], @start, 20)
        failures_view(:failure_queue)
      end
      
      app.post '/failed/:queue/clear' do
        Resque::Failure.backend.clear(params[:queue])
        redirect u("failure/#{params[:queue]}")
      end
      
      app.get '/failed/:queue/requeue/:id' do
        Resque::Failure.backend.requeue(params[:queue], params[:id])
        if request.xhr?
          return Resque::Failure.backend.all(params[:queue], params[:index])['retried_at']
        else
          redirect u("failure/#{params[:queue]}")
        end
      end
      
      app.helpers do
        def failures_view(filename, options = {}, locals = {})
          erb(File.read(File.join(::Resque::FailureServer::VIEW_PATH, "#{filename}.erb")), options, locals)
        end
      end
    end
    
  end
end

Resque::Server.register Resque::FailureServer

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resque-multiple-failure-backend-1.1.1 lib/resque/failure_server.rb
resque-multiple-failure-backend-1.1.0 lib/resque/failure_server.rb
resque-multiple-failure-backend-1.0.1 lib/resque/failure_server.rb