
Cantella::Worker::Role::Worker - Polling POE worker

package TestWorkerPool;
use Moose;
with 'Cantella::Worker::Role::Worker';
my @work_stack = ( 1 .. 10);
sub get_work {
my $self = shift;
if( @work_stack ){
return shift @work_stack;
} else {
$self->shutdown;
return;
}
}
sub work {
my ($self, $args) = @_;
sleep(1);
}

Should return undef if there's no work avaliable and a single defined scalar representing the inputs to the work if there is.
Do whatever!

Read-only Log::Dispatch instance. Defaults to a device that logs to Null. This attribute can coerce from a hash or array reference, see MooseX::Types::Log::Dispatch for details.
Read-write integer. The number of seconds to wait between poll events. Will default to 2 seconds.
Read-only string. This is the alias of the session managing the workers and will default to a UUID string by default.

after BUILD Sets up the polling session and its event handlers.
Begin the event loop
Stop polling for work.
Resume polling for work.
Stop polling for work and end the session after current jobs are done.

The following methods are POE event handlers. They are not meant to be called directly and will not work if you do. When applicable, arguments will be passed into the methods in ARG0, ARG1, etc.
Poll for work. If we find work, schedule another poll event due to execute after the work event. If no jobs are found, schedule the next poll for interval seconds in the future. This ensures that the worker will always be busy while there is work, but will control it's polling for work when there isn't any available.
Do this one job.
Start the polling process
Pause the polling process until $until
Resume the polling process
Remove all alarms and wait for the session to die

shutdownshutdown_pause_resume
Cantella::Worker::Manager::Prefork, Cantella::Worker::Role::Beanstalk

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.