Cantella::Worker::Role::Beanstalk - Fetch Cantella::Worker jobs from beanstalkd
package TestWorkerPool; use Try::Tiny; use Moose; with( 'Cantella::Worker::Role::Worker', 'Cantella::Worker::Role::Beanstalk' ); sub work { my ($self, $job) = @_; my @args = $job->args; try { if( do_something(@args) ){ $job->delete; #work done successfully } else { $job->release({delay => 10}); #let's try again in 10 seconds } } catch { $job->bury; #job failed, bury it and log to file $self->logger->error("Burying job ".$job->id." due to error: '$_'"); }; }
Read-only, required, ArrayRef of Beanstalk::Client instances.
Read-only integer. The reserve timeout will be passed on to Beanstalk::Client's reserve method, and signals how long, in seconds, the client should wait for a job to become available before timing out and trying the next client in the pool.
reserve
WARNING: If you only have one Beanstalk server, you might be tempted to set not time out. Don't do this. By setting no timeout, the reserve command will block all other events, including signal handlers. Instead, it is suggested that the reserve_timeout is set to something that is resonable for you workload and the load of your beanstalkd process.
reserve_timeout
Read-only, Integer. After a job has been reserved more than max_tries, it will be deleted and not attempted again.
max_tries
Reas-only boolean. If delet_on_max_tries is set to true and any job exceeds max_tries, the job will be deleted from the pool, otherwise the job will be buryed. The value defaults to false. This attribue has no effect unless max_tries is set.
delet_on_max_tries
bury
$beanstalk_job
Will attempt to reserve a job from all of the clients and return it.
The _start method is extended to disconnect and reconnect to the beanstalk servers. This ensures that if a client instance is passed in as an argument prior to a fork when using Cantella::Worker::Manager::Prefork, the connection works correctly in the child.
_start
Cantella::Worker::Manager::Prefork, Cantella::Worker::Role::Worker
Guillermo Roditi (groditi) <groditi@cpan.org>
This software is copyright (c) 2009-2010 by Guillermo Roditi. This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Cantella::Worker::Role::Beanstalk, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Cantella::Worker::Role::Beanstalk
CPAN shell
perl -MCPAN -e shell install Cantella::Worker::Role::Beanstalk
For more information on module installation, please visit the detailed CPAN module installation guide.