File: //usr/local/ssl/local/share/man/man3/Cpanel::TaskQueue::Processor.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Cpanel::TaskQueue::Processor 3"
.TH Cpanel::TaskQueue::Processor 3 "2011-09-16" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
Cpanel::TaskQueue::Processor \- Processes an individual task from the Cpanel::TaskQueue.
.SH "VERSION"
.IX Header "VERSION"
This document describes Cpanel::TaskQueue::Processor version 0.307.
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& package NewTask;
.Ve
.PP
.Vb 1
\& use base 'Cpanel::TaskQueue::Processor';
.Ve
.PP
.Vb 2
\& sub process_task {
\& my ($self, $task) = @_;
.Ve
.PP
.Vb 1
\& # do something exciting.
.Ve
.PP
.Vb 2
\& return;
\& }
.Ve
.PP
.Vb 5
\& sub is_valid_args {
\& my ($self, $task) = @_;
\& # all args must be numeric
\& return !grep { /[^-\ed]/ } $task->args();
\& }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module provides an abstraction for commands to be executed from/by the
TaskQueue. It is used as a base class to provide default behavior for every
method except \f(CW\*(C`process_task\*(C'\fR that is used by the \f(CW\*(C`Cpanel::TaskQueue\*(C'\fR.
.SH "PUBLIC METHODS"
.IX Header "PUBLIC METHODS"
.IP "Cpanel::TaskQueue::Processor\->new" 4
.IX Item "Cpanel::TaskQueue::Processor->new"
Create a new \f(CW\*(C`Cpanel::TaskQueue::Processor\*(C'\fR object.
.ie n .IP "$proc\->is_dupe( $task_a\fR, \f(CW$task_b )" 4
.el .IP "$proc\->is_dupe( \f(CW$task_a\fR, \f(CW$task_b\fR )" 4
.IX Item "$proc->is_dupe( $task_a, $task_b )"
Return true if the two supplied \f(CW\*(C`Cpanel::TaskQueue::Task\*(C'\fR objects are equivalent.
The parameters are guaranteed not to be \f(CW\*(C`undef\*(C'\fR.
.Sp
The method should return a true value if the parameters are duplicates and a
false value if they are not. If the method fails for some reason, throw an
exception.
.Sp
A subclass might want to override this to give more specific processing. The
default definition is to check if the arguments for the two supplied task
descriptors is the same. If so, return true, else return \f(CW\*(C`undef\*(C'\fR.
.ie n .IP "$proc\->overrides( $new_task\fR, \f(CW$old_task )" 4
.el .IP "$proc\->overrides( \f(CW$new_task\fR, \f(CW$old_task\fR )" 4
.IX Item "$proc->overrides( $new_task, $old_task )"
Return true if the \fInew_task\fR \f(CW\*(C`Cpanel::TaskQueue::Task\*(C'\fR object should override
the \fIold_task\fR object. The parameters are guaranteed not to be \f(CW\*(C`undef\*(C'\fR.
.Sp
The method should return a true value if there is no need to execute the \fIold_task\fR
since the \fInew_task\fR results will override whatever \fIold_task\fR was going to
do. For example, if the old task changes a user's password, and the new task
deletes that user, there is no need to run the first task. Otherwise the method
should return a false value. If the method fails for some reason, throw an
exception.
.Sp
A subclass might want to override this to give more specific processing. The
default definition is aways return \f(CW\*(C`undef\*(C'\fR.
.ie n .IP "$proc\->is_valid_args( $task )" 4
.el .IP "$proc\->is_valid_args( \f(CW$task\fR )" 4
.IX Item "$proc->is_valid_args( $task )"
Return true if the arguments in the supplied Cpanel::TaskQueue::Task are valid
for this task. The parameter is guaranteed not to be \f(CW\*(C`undef\*(C'\fR.
.Sp
The method should return a true value if the supplied task has valid arguments
for the command, otherwise it should return false. If the method fails for some
reason, the method should throw an exception.
.Sp
A subclass will probably want to override this method for more specific processing.
The default definition is to return true regardless of the state of the supplied
task descriptor.
.ie n .IP "$proc\->process_task( $task\fR, \f(CW$logger )" 4
.el .IP "$proc\->process_task( \f(CW$task\fR, \f(CW$logger\fR )" 4
.IX Item "$proc->process_task( $task, $logger )"
Perform the task that is described by the supplied Cpanel::TaskQueue::Task. The
parameter is guaranteed not to be \f(CW\*(C`undef\*(C'\fR. The \f(CW$logger\fR parameter is an object
providing logging facilities for the system. See \*(L"#LOGGER \s-1OBJECT\s0\*(R" in Cpanel::TaskQueue
for the interface of this object.
.Sp
This method should return a 0 if the code processing is complete. If the processing
spawns a child to handle the work, the method should return the pid of the child.
If the processing fails, it should throw an exception.
.Sp
A subclass must override this method to get any processing. The default throws
an exception if called.
.IP "$proc\->\fIget_timeout()\fR" 4
.IX Item "$proc->get_timeout()"
Return the number of seconds before the task should be considered \fItimed out\fR.
The default method returns \f(CW\*(C`undef\*(C'\fR. Any false value uses whatever the default
value for the TaskQueue defines. A subclass may override this method to provide
a longer time out value for cases where the processing is known to take some
time.
.SH "UTILITY METHODS"
.IX Header "UTILITY METHODS"
This section describes convenience methods that may be useful to classes
derived from the \f(CW\*(C`Processor\*(C'\fR class.
.ie n .IP "$proc\->checked_system( $hashref )" 4
.el .IP "$proc\->checked_system( \f(CW$hashref\fR )" 4
.IX Item "$proc->checked_system( $hashref )"
In many cases, the task to be processed depends on running another program.
Since handling the return code from \f(CW\*(C`system\*(C'\fR is annoying, it often gets
ignored. This method calls the core system routine, and checks the return
code. It logs an appropriate message for error conditions and is quiet on
success. \f(CW\*(C`checked_system\*(C'\fR returns the same return code as \f(CW\*(C`system\*(C'\fR.
.Sp
The method expects a \f(CW\*(C`hash ref\*(C'\fR describing the request. The parameters in the
hash ref are:
.RS 4
.IP "logger" 4
.IX Item "logger"
This required parameter should provide an object following the logging
interface described in \*(L"#LOGGER \s-1OBJECT\s0\*(R" in Cpanel::TaskQueue. If this parameter
is missing, the method throws an exception.
.IP "name" 4
.IX Item "name"
This required parameter provides a name used in any error messages. If this
parameter is missing, the method throws an exception.
.IP "cmd" 4
.IX Item "cmd"
This required parameter provides the command that system is to execute. If this
parameter is missing, the method throws an exception.
.IP "args" 4
.IX Item "args"
This optional parameter is an array reference containing the parameters to pass
with the command to the \f(CW\*(C`system\*(C'\fR call. If this parameter is missing, an empty
list is assumed.
.RE
.RS 4
.RE
.SH "DIAGNOSTICS"
.IX Header "DIAGNOSTICS"
.ie n .IP """No processing has been specified for this task.""" 4
.el .IP "\f(CWNo processing has been specified for this task.\fR" 4
.IX Item "No processing has been specified for this task."
Either this base class has been used directly as a processor for a command or
the \f(CW\*(C`process_task\*(C'\fR method was not overridden in a derived class.
.Sp
In either case, the default behavior for \f(CW\*(C`process_task\*(C'\fR is to throw an exception.
.SH "CONFIGURATION AND ENVIRONMENT"
.IX Header "CONFIGURATION AND ENVIRONMENT"
Cpanel::TaskQueue::Processor requires no configuration files or environment variables.
.SH "DEPENDENCIES"
.IX Header "DEPENDENCIES"
None.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Cpanel::TaskQueue, Cpanel::TaskQueue::Task
.SH "INCOMPATIBILITIES"
.IX Header "INCOMPATIBILITIES"
None reported.
.SH "BUGS AND LIMITATIONS"
.IX Header "BUGS AND LIMITATIONS"
No bugs have been reported.
.SH "AUTHOR"
.IX Header "AUTHOR"
G. Wade Johnson \f(CW\*(C`wade@cpanel.net\*(C'\fR
.SH "LICENCE AND COPYRIGHT"
.IX Header "LICENCE AND COPYRIGHT"
Copyright (c) 2009, CPanel. All rights reserved.
.PP
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See perlartistic.
.SH "DISCLAIMER OF WARRANTY"
.IX Header "DISCLAIMER OF WARRANTY"
\&\s-1BECAUSE\s0 \s-1THIS\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1LICENSED\s0 \s-1FREE\s0 \s-1OF\s0 \s-1CHARGE\s0, \s-1THERE\s0 \s-1IS\s0 \s-1NO\s0 \s-1WARRANTY\s0
\&\s-1FOR\s0 \s-1THE\s0 \s-1SOFTWARE\s0, \s-1TO\s0 \s-1THE\s0 \s-1EXTENT\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0. \s-1EXCEPT\s0 \s-1WHEN\s0
\&\s-1OTHERWISE\s0 \s-1STATED\s0 \s-1IN\s0 \s-1WRITING\s0 \s-1THE\s0 \s-1COPYRIGHT\s0 \s-1HOLDERS\s0 \s-1AND/OR\s0 \s-1OTHER\s0 \s-1PARTIES\s0
\&\s-1PROVIDE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EITHER\s0
\&\s-1EXPRESSED\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0, \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0, \s-1THE\s0 \s-1IMPLIED\s0
\&\s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. \s-1THE\s0
\&\s-1ENTIRE\s0 \s-1RISK\s0 \s-1AS\s0 \s-1TO\s0 \s-1THE\s0 \s-1QUALITY\s0 \s-1AND\s0 \s-1PERFORMANCE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1WITH\s0
\&\s-1YOU\s0. \s-1SHOULD\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1PROVE\s0 \s-1DEFECTIVE\s0, \s-1YOU\s0 \s-1ASSUME\s0 \s-1THE\s0 \s-1COST\s0 \s-1OF\s0 \s-1ALL\s0
\&\s-1NECESSARY\s0 \s-1SERVICING\s0, \s-1REPAIR\s0, \s-1OR\s0 \s-1CORRECTION\s0.
.PP
\&\s-1IN\s0 \s-1NO\s0 \s-1EVENT\s0 \s-1UNLESS\s0 \s-1REQUIRED\s0 \s-1BY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