1- [ ![ Build Status] ( https://travis-ci.org/CpanelInc/cPanel-TaskQueue.png?branch=master )] ( https://travis-ci.org/CpanelInc/cPanel-TaskQueue )
2-
31# NAME
42
53cPanel::TaskQueue - FIFO queue of tasks to perform
64
75# SYNOPSIS
86
9- use cPanel::TaskQueue ();
7+ ``` perl
8+ use cPanel::TaskQueue ();
109
11- my $queue = cPanel::TaskQueue->new( { name => 'tasks', state_dir => "/home/$user/.cpanel/queue" } );
10+ my $queue = cPanel::TaskQueue-> new( { name => ' tasks' , state_dir => " /home/$user /.cpanel/queue" } );
1211
13- $queue->queue_task( "init_quota" );
14- $queue->queue_task( "edit_quota fred 0" );
15- $queue->queue_tasks( "init_quota", "edit_quota fred 0" );
12+ $queue -> queue_task( " init_quota" );
13+ $queue -> queue_task( " edit_quota fred 0" );
14+ $queue -> queue_tasks( " init_quota" , " edit_quota fred 0" );
1615
17- # Processing loop
18- while (1) {
19- # if work, process, else sleep
20- if ( $queue->has_work_to_do() ) {
21- eval { $queue->process_next_task() };
22- if ( $@ ) {
23- Carp::carp( $@ );
24- }
25- }
26- else {
27- # wait for work.
28- sleep 300;
16+ # Processing loop
17+ while (1) {
18+ # if work, process, else sleep
19+ if ( $queue -> has_work_to_do() ) {
20+ eval { $queue -> process_next_task() };
21+ if ( $@ ) {
22+ Carp::carp( $@ );
2923 }
3024 }
25+ else {
26+ # wait for work.
27+ sleep 300;
28+ }
29+ }
30+ ```
3131
3232# DESCRIPTION
3333
392392To provide a different method of logging/reporting, supply an object to do the
393393logging as follows when ` use ` ing the module.
394394
395- use cPanel::TaskQueue ( '-logger' => $logger );
395+ ``` perl
396+ use cPanel::TaskQueue ( ' -logger' => $logger );
397+ ```
396398
397399The supplied object should supply (at least) 4 methods: ` throw ` , ` warn ` ,
398400` info ` , and ` notify ` . When needed these methods will be called with the
@@ -404,7 +406,7 @@ multiple modules and expect it to work.
404406In addition to setting a global logger, a new logger object can be supplied
405407when creating a specific ` TaskQueue ` object.
406408
407- See [ cPanel::TaskQueue::Cookbook] ( https://metacpan.org/pod/cPanel::TaskQueue::Cookbook ) for examples.
409+ See [ cPanel::TaskQueue::Cookbook] ( https://metacpan.org/pod/cPanel%3A%3ATaskQueue%3A%3ACookbook ) for examples.
408410
409411# DIAGNOSTICS
410412
0 commit comments