MyCPAN::Indexer::Tutorial - How the backpan_indexer.pl pieces fit together
The MyCPAN::Indexer system lets you plug in different engines to control major portions of the process. It's up to each class to obey the interface and do that parts the other portions it expects it to do. The idea is to decouple some of these bits as much as possible.
As backpan_indexer.pl does its work, it stores information about its components in an anonymous hash called $Notes. The different components have access to this hash. (To Do: this is some pretty bad design smell, but that's how it is right now).
backpan_indexer.pl
$Notes
Specific implementations will impose other requirements not listed in this tutorial.
The Queue class is responsible for getting the list of distributions to process.
backpan_indexer.pl calls get_queue and passes it a ConfigReader::Simple object. get_queue does whatever it needs to do, then returns an array reference of file paths to process. Each path should represent a single Perl distribution.
get_queue
Implements:
get_queue( $Notes )
Creates in $Notes:
queue - a reference to the array reference returned by get_queue.
Expects in $Notes:
config - the configuration object
To Do: The Queue class should really be an iterator of some sort. Instead of returning an array (which it can't change), return an iterator.
The Worker class returns the anonymous subroutine that the interface class calls for each of its cycles. Inside that code reference, do the actual indexing work, including saving the results. backpan_indexer.pl calls get_task with a reference to its $Notes hash.
get_task
get_task( $Notes )
Creates in $Notes
child_task - a reference to the code reference returned by get_task.
Expects in $Notes
To Do: There should be a storage class which the worker class hands the results to.
The Dispatcher class implements the bits to hand out work to the worker class. The Interface class, discussed next, repeatedly calls the interface_callback code ref the Dispatcher class provides.
get_dispatcher( $Notes )
dispatcher - the dispatcher object, with start and finish methods interface_callback - a code ref to call repeatedly in the Interface class
config - the configuration object child_task - the code ref that handles indexing a single dist queue - the array ref of dist paths
The Interface class really has two jobs. It makes the live reporting interface while backpan_indexer.pl runs, at it repeatedly calls the dispatcher to start new work.
go_interface( $Notes )
config - the configuration object interface_callback - a code ref to call repeatedly in the Interface class
MyCPAN::Indexer
This code is in Github:
git://github.com/briandfoy/mycpan-indexer.git
brian d foy, <bdfoy@cpan.org>
<bdfoy@cpan.org>
Copyright (c) 2008, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.
To install MyCPAN::Indexer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MyCPAN::Indexer
CPAN shell
perl -MCPAN -e shell install MyCPAN::Indexer
For more information on module installation, please visit the detailed CPAN module installation guide.