Data-Consumer
view release on metacpan or search on metacpan
lib/Data/Consumer.pm view on Meta::CPAN
=head2 The Consumer Pattern
The consumer pattern is where code wants to consume an 'atomic' resource
piece by piece. The consuming code doesn't really want to worry much
about how they got the piece, a task that should be handled by the framework.
The consumer subclasses assume that the resource can be modeled as a
queue (that there is some ordering principle by which they can be processed
in a predictable sequence). The consume pattern in full glory is something
very close to the following following pseudo code. The items marked with
asterisks are where user callbacks may be invoked:
DO
RESET TO THE BEGINNING OF THE QUEUE
WHILE QUEUE NOT EMPTY AND CAN *PROCEED*
ACQUIRE NEXT ITEM TO PROCESS FROM QUEUE
MARK AS 'WORKING'
*PROCESS* ITEM
IF PROCESSING FAILED
MARK AS 'FAILED'
OTHERWISE
lib/Data/Consumer.pm view on Meta::CPAN
my $id= $self->last_id;
$self->{ignore}{$id}++;
$self->leave;
}
return $self;
}
=head2 $consumer->fail($message)
Same as doing C<die($message)> from within a consume/process callback except
that no exception is thrown (no C<$SIG{__DIE__}> callbacks are invoked) and
the error is deferred until the callback actually returns.
Typically used as
return $consumer->fail;
from within a consumer() callback.
Returns the $consumer object.
( run in 0.334 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )