DR::TarantoolQueue::Worker - template for workers
my $worker = DR::TarantoolQueue::Worker->new( count => 10, # defaults 1 queue => $queue ); sub process { my ($task) = @_; ... do something with task } $worker->run(\&process)
Process function can throw exception. The task will be buried (if process function didn't change task status yet.
If process function didn't change task status (didn't call ack, or "release" in DR::TarantoolQueue::Task) worker calls "ack" in DR::TarantoolQueue::Task.
run method catches SIGTERM and SIGINT and waits for all process functions are done and then do return.
Worker uses default tube and space in queue. So You have to define them in Your queue or here.
Count of process functions that can do something at the same time. Default value is 1. The attribute means something if Your process function uses Coro and Your queue uses Coro, too.
List of queues.
Space and tube for processing queue.
The function will be called if restart_limit is reached.
How many tasks can be processed before restart worker.
If restart_limit is 0, restart mechanizm will be disabled.
If restart callback isn't defined, restart mechanizm will be disabled.
Each processed task increments common taskcounter. When restart_limit is reached by the counter, worker don't take new task and call restart function. After restart worker will continue to process tasks.
In restart callback user can do "exec" in perlfunc or "exit" in perlfunc to avoid memory leaks.
DR::TarantoolQueue::Worker->new( restart_limit => 100, restart => sub { exec perl => $0 }, queue => $q, count => 10 )->run(sub { ... });
timeout for queue.take
True means that workers are run
True means that workers are stopping (by SIGTERM/SIGINT/stop)
Run workers. Two arguments:
Function will receive three arguments:
The function can be used to show internal debug messages.
Debug messages aren't finished by EOL (\n).
\n
The function will be called as "sprintf" in perlfunc.
Send mail about worker crash
Stop worker cycle
To install DR::TarantoolQueue, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DR::TarantoolQueue
CPAN shell
perl -MCPAN -e shell install DR::TarantoolQueue
For more information on module installation, please visit the detailed CPAN module installation guide.