Data-Consumer
view release on metacpan or search on metacpan
lib/Data/Consumer.pm view on Meta::CPAN
=head2 CLASS->new(%opts)
Constructor. Normally L<Data::Consumer>'s constructor is not called
directly, instead the constructor of a subclass is used. However to
make it easier to have a data driven load process L<Data::Consumer>
accepts the C<type> argument which should specify the the short name of
the subclass (the part after C<Data::Consumer::>) or the full name of
the subclass.
Thus
Data::Consumer->new(type=>'MySQL',%args);
is exactly equivalent to calling
Data::Consumer::MySQL->new(%args);
except that the former will automatically require or use the appropriate module
and the latter necessitates that you do so yourself.
Every L<Data::Consumer> subclass constructor supports the following
arguments on top of any that are subclass specific. Additionally some
arguments are universally used, but have different meaning depending on
the subclass.
=over 4
=item unprocessed
How to tell if the item is unprocessed.
How this argument is interpreted depends on the L<Data::Consumer>
subclass involved.
=item working
How to tell if the item is currently being worked on.
How this argument is interpreted depends on the L<Data::Consumer>
subclass involved.
=item processed
How to tell if the item has already been worked on.
How this argument is interpreted depends on the L<Data::Consumer>
subclass involved.
=item failed
How to tell if processing failed while handling the item.
How this argument is interpreted depends on the L<Data::Consumer>
subclass involved.
=item max_passes => $num_or_undef
Normally C<consume()> will loop through the data set until it is
exhausted. By setting this parameter you can control the maximum number
of iterations, for instance setting it to C<1> will result in a single
pass through the data per invocation. If C<0> (or any other false value)
is treated as meaning "loop until exhausted".
=item max_processed => $num_or_undef
Maximum number of items to process per invocation.
If set to a false value there is no limit.
=item max_failed => $num_or_undef
Maximum number of failed process attempts that may occur before consume will stop.
If set to a false value there is no limit. Setting this to 1 will cause processing
to stop after the first failure.
=item max_elapsed => $seconds_or_undef
Maximum amount of time that may have elapsed when starting a new
process. If more than this value has elapsed then no further processing
occurs. If C<0> (or any false value) then there is no time limit.
=item proceed => $code_ref
This is a callback that may be used to control the looping process in
consume via the C<proceed()> method. See the documentation of
C<consume()> and C<proceed()>
=item sweep => $bool
*** NOTE CURRENTLY THIS OPTION IS DISABLED ***
If this parameter is true, and there are four modes defined
(C<unprocessed>, C<working>, C<processed>, C<failed>) then consume will
perform a "sweep up" after every pass, which is responsible for moving
"abandonded" files from the working directory (such as from a previous
process that segfaulted during processing). Generally this should
not be necessary.
=back
=head2 CLASS->register(@alias)
Used by subclasses to register themselves as a L<Data::Consumer>
subclass and register any additional aliases that the class may be
identified as.
Will throw an exception if any of the aliases are already associated to
a different class.
When called on a subclass in list context returns a list of the
subclasses registered aliases,
If called on L<Data::Consumer> in list context returns a list of all
alias class mappings.
=cut
( run in 1.910 second using v1.01-cache-2.11-cpan-71847e10f99 )