NAME
DataFlow - A framework for dataflow processing
VERSION
version 1.111500
SYNOPSIS
use DataFlow;
my $flow = DataFlow->new(
procs => [
DataFlow::Proc->new( p => sub { do this thing } ),
sub { ... do something },
sub { ... do something else },
CSV => {
direction => 'TO_CSV',
text_csv_opts => { binary => 1 },
},
]
);
$flow->input( <some input> );
my $output = $flow->output();
my $output = $flow->output( <some other input> );
DESCRIPTION
A DataFlow
object is able to accept data, feed it into an array of processors (DataFlow::Proc objects), and return the result(s) back to the caller.
ATTRIBUTES
name
[Str] A descriptive name for the dataflow. (OPTIONAL)
auto_process
[Bool] If there is data available in the output queue, and one calls the output()
method, this attribute will flag whether the dataflow should attempt to automatically process queued data. (DEFAULT: true)
procs
[ArrayRef[DataFlow::Proc]] The list of processors that make this DataFlow. Optionally, you may pass CodeRefs that will be automatically converted to DataFlow::Proc objects. (REQUIRED)
The procs
parameter will accept some variations in its value. Any ArrayRef
passed will be parsed, and additionaly to plain DataFlow::Proc
objects, it will accept: DataFlow
objects (so one can nest flows), code references (sub{}
blocks) and plain text strings.
The text string form is treatedi, for a given "TEXT", in the following order: if it contains '::' then DataFlow will try to use a class named "TEXT"; it that doesn't work (or if it doesn't contain '::'), DataFlow will try to load a class named 'DataFlow::Proc::TEXT'; if that fails, it tries one last time to load a class named 'TEXT'. If that last try doesn't work, it dies.
Additionally, one may pass any of these forms as a single argument to the constructor new
, plus a single DataFlow
, or DataFlow:Proc
or string.
METHODS
has_queued_data
Returns true if the dataflow contains any queued data within.
clone
Returns another instance of a DataFlow
using the same array of processors.
input
Accepts input data for the data flow. It will gladly accept anything passed as parameters. However, it must be noticed that it will not be able to make a distinction between arrays and hashes. Both forms below will render the exact same results:
$flow->input( qw/all the simple things/ );
$flow->input( all => 'the', simple => 'things' );
If you do want to handle arrays and hashes differently, we strongly suggest that you use references:
$flow->input( [ qw/all the simple things/ ] );
$flow->input( { all => the, simple => 'things' } );
Processors with process_into
enabled (true by default) will process the items inside an array reference, and the values (not the keys) inside a hash reference.
process_input
Processes items in the array of queues and place at least one item in the output (last) queue. One will typically call this to flush out some unwanted data and/or if auto_process
has been disabled.
output
Fetches data from the data flow. If called in scalar context it will return one processed item from the flow. If called in list context it will return all the elements in the last queue.
flush
Flushes all the data through the dataflow, and returns the complete result set.
process
Immediately processes a bunch of data, without touching the object queues. It will process all the provided data and return the complete result set for it.
HISTORY
This is a framework for data flow processing. It started as a spinoff project from the OpenData-BR initiative.
As of now (Mar, 2011) it is still a 'work in progress', and there is a lot of progress to make. It is highly recommended that you read the tests, and the documentation of DataFlow::Proc, to start with.
An article has been recently written in Brazilian Portuguese about this framework, per the São Paulo Perl Mongers "Equinócio" (Equinox) virtual event. Although an English version of the article in in the plans, you can figure a good deal out of the original one at
http://sao-paulo.pm.org/equinocio/2011/mar/5
UPDATE: DataFlow is a fast-evolving project, and this article, as it was published there, refers to versions 0.91.x of the framework. There has been a big refactor since then and, although the concept remains the same, since version 0.950000 the programming interface has been changed violently.
Any doubts, feel free to get in touch.
AUTHOR
Alexei Znamensky <russoz@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Alexei Znamensky.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
SUPPORT
Perldoc
You can find documentation for this module with the perldoc command.
perldoc DataFlow
Websites
The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.
Search CPAN
The default CPAN search engine, useful to view POD in HTML format.
AnnoCPAN
The AnnoCPAN is a website that allows community annonations of Perl module documentation.
CPAN Ratings
The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.
CPAN Forum
The CPAN Forum is a web forum for discussing Perl modules.
CPANTS
The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
CPAN Testers
The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions.
CPAN Testers Matrix
The CPAN Testers Matrix is a website that provides a visual way to determine what Perls/platforms PASSed for a distribution.
Internet Relay Chat
You can get live help by using IRC ( Internet Relay Chat ). If you don't know what IRC is, please read this excellent guide: http://en.wikipedia.org/wiki/Internet_Relay_Chat. Please be courteous and patient when talking to us, as we might be busy or sleeping! You can join those networks/channels and get help:
irc.perl.org
You can connect to the server at 'irc.perl.org' and join this channel: #opendata-br to get help.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://github.com/russoz/DataFlow/issues.
AVAILABILITY
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/DataFlow/.
The development version lives at http://github.com/russoz/DataFlow and may be cloned from git://github.com/russoz/DataFlow.git. Instead of sending patches, please fork this project using the standard git and github infrastructure.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.