Queue::Worker - Database based work queue abstraction.
package MyWorker; use base 'Queue::Worker'; sub name { 'my_work'; } sub process { my ($self, $item) = @_; # do your work here } # create worker table in db MyWorker->create_table($dbh); # and somewhere else MyWorker->enqueue($dbh, 'some work order string'); # and finally to run the queue MyWorker->run($dbh);
This module provides simple, database queue based, worker abstraction. It provides locking between worker instances using POSIX::RT::Semaphore.
Strings representing work orders are enqueued with enqueue function. Those items are removed from the queue by run function.
enqueue
run
Creates table queue_worker_$name table in the database. $name parameter is optional: if undef name accessor is used.
queue_worker_$name
$name
name
Enqueues work order $msg into the queue.
$msg
Creates new instance of the worker. Also creates underlying semaphore.
Runs the queue. Calls process method on each work item.
process
Unlinks semaphore.
Returns underlying semaphore.
The following methods should be implemented by inherited class.
Should return the name of the worker.
Callback to process the work order.
Boris Sukholitko CPAN ID: BOSU boriss@gmail.com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
POSIX::RT::Semaphore
To install Queue::Worker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Queue::Worker
CPAN shell
perl -MCPAN -e shell install Queue::Worker
For more information on module installation, please visit the detailed CPAN module installation guide.