NAME
Resque::Failures - Class for managing Resque failures
VERSION
version 0.32
ATTRIBUTES
resque
Accessor to the Resque object.
failure_class
Name of a class consuming the role 'Resque::Failure'. By default: Resque::Failure::Redis
METHODS
throw
create() a failure on the failure_class() and save() it.
$failures->throw( %job_description_hash );
See Resque code for a usage example.
create
Create a new failure on the failure_class() backend.
$failures->create( ... );
count
How many failures are in the resque system.
my $count = $failures->count();
all
Return a range of failures (or an arrayref in scalar context) in the same way Resque::peek() does for jobs.
my @failures = $failures->all('my_queue', $opt_start, $opt_count);
clear
Remove all failures.
$failures->clear();
requeue
Requeue by index number.
Failure will be updated to note retried date.
$failures->requeue( $index );
remove
Remove failure by index number in failures queue.
Please note that, when you remove some index, all sucesive ones will move left, so index will decrese one. If you want to remove several ones start removing from the rightmost one.
$failures->remove( $index );
mass_remove
Remove and optionally requeue all or matching failed jobs. Errors that happen after this method is fired will remind untouched.
Filters, if present, are useful to select failed jobs and should be regexes or strings that will be matched against any of the following failed job field:
queue: the queue where job had failed
class: the job class
error: the error string
args: a JSON representation of the job arguments
By default, all matching jobs will be deleted but the ones that doesn't match will be placed back at the end of the failed jobs.
The behavior can be modified with the following options:
requeue: requeue matching jobs after being removed.
requeue_to: Requeued jobs will be placed on this queue instead of the original one. This option implies requeue.
Example
# Remove and requeue all failed jobs from queue 'test_queue' of class My::Job::Class
$resque->failures->mass_remove(
queue => 'test_queue',
class => qr/^My::Job::Class$/,
requeue => 1
);
AUTHOR
Diego Kuperman <diego@freekeylabs.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Diego Kuperman.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.