.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .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. \*(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- .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" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Minion::Backend 3pm" .TH Minion::Backend 3pm "2017-01-04" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Minion::Backend \- Backend base class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package Minion::Backend::MyBackend; \& use Mojo::Base \*(AqMinion::Backend\*(Aq; \& \& sub broadcast {...} \& sub dequeue {...} \& sub enqueue {...} \& sub fail_job {...} \& sub finish_job {...} \& sub job_info {...} \& sub list_jobs {...} \& sub list_workers {...} \& sub receive {...} \& sub register_worker {...} \& sub remove_job {...} \& sub repair {...} \& sub reset {...} \& sub retry_job {...} \& sub stats {...} \& sub unregister_worker {...} \& sub worker_info {...} .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Minion::Backend is an abstract base class for Minion backends, like Minion::Backend::Pg. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Minion::Backend implements the following attributes. .SS "minion" .IX Subsection "minion" .Vb 2 \& my $minion = $backend\->minion; \& $backend = $backend\->minion(Minion\->new); .Ve .PP Minion object this backend belongs to. .SH "METHODS" .IX Header "METHODS" Minion::Backend inherits all methods from Mojo::Base and implements the following new ones. .SS "broadcast" .IX Subsection "broadcast" .Vb 3 \& my $bool = $backend\->broadcast(\*(Aqsome_command\*(Aq); \& my $bool = $backend\->broadcast(\*(Aqsome_command\*(Aq, [@args]); \& my $bool = $backend\->broadcast(\*(Aqsome_command\*(Aq, [@args], [$id1, $id2, $id3]); .Ve .PP Broadcast remote control command to one or more workers. .SS "dequeue" .IX Subsection "dequeue" .Vb 2 \& my $job_info = $backend\->dequeue($worker_id, 0.5); \& my $job_info = $backend\->dequeue($worker_id, 0.5, {queues => [\*(Aqimportant\*(Aq]}); .Ve .PP Wait a given amount of time in seconds for a job, dequeue it and transition from \&\f(CW\*(C`inactive\*(C'\fR to \f(CW\*(C`active\*(C'\fR state, or return \f(CW\*(C`undef\*(C'\fR if queues were empty. Meant to be overloaded in a subclass. .PP These options are currently available: .IP "queues" 2 .IX Item "queues" .Vb 1 \& queues => [\*(Aqimportant\*(Aq] .Ve .Sp One or more queues to dequeue jobs from, defaults to \f(CW\*(C`default\*(C'\fR. .PP These fields are currently available: .IP "args" 2 .IX Item "args" .Vb 1 \& args => [\*(Aqfoo\*(Aq, \*(Aqbar\*(Aq] .Ve .Sp Job arguments. .IP "id" 2 .IX Item "id" .Vb 1 \& id => \*(Aq10023\*(Aq .Ve .Sp Job \s-1ID.\s0 .IP "retries" 2 .IX Item "retries" .Vb 1 \& retries => 3 .Ve .Sp Number of times job has been retried. .IP "task" 2 .IX Item "task" .Vb 1 \& task => \*(Aqfoo\*(Aq .Ve .Sp Task name. .SS "enqueue" .IX Subsection "enqueue" .Vb 3 \& my $job_id = $backend\->enqueue(\*(Aqfoo\*(Aq); \& my $job_id = $backend\->enqueue(foo => [@args]); \& my $job_id = $backend\->enqueue(foo => [@args] => {priority => 1}); .Ve .PP Enqueue a new job with \f(CW\*(C`inactive\*(C'\fR state. Meant to be overloaded in a subclass. .PP These options are currently available: .IP "attempts" 2 .IX Item "attempts" .Vb 1 \& attempts => 25 .Ve .Sp Number of times performing this job will be attempted, with a delay based on \&\*(L"backoff\*(R" in Minion after the first attempt, defaults to \f(CW1\fR. .IP "delay" 2 .IX Item "delay" .Vb 1 \& delay => 10 .Ve .Sp Delay job for this many seconds (from now). .IP "parents" 2 .IX Item "parents" .Vb 1 \& parents => [$id1, $id2, $id3] .Ve .Sp One or more existing jobs this job depends on, and that need to have transitioned to the state \f(CW\*(C`finished\*(C'\fR before it can be processed. .IP "priority" 2 .IX Item "priority" .Vb 1 \& priority => 5 .Ve .Sp Job priority, defaults to \f(CW0\fR. Jobs with a higher priority get performed first. .IP "queue" 2 .IX Item "queue" .Vb 1 \& queue => \*(Aqimportant\*(Aq .Ve .Sp Queue to put job in, defaults to \f(CW\*(C`default\*(C'\fR. .SS "fail_job" .IX Subsection "fail_job" .Vb 4 \& my $bool = $backend\->fail_job($job_id, $retries); \& my $bool = $backend\->fail_job($job_id, $retries, \*(AqSomething went wrong!\*(Aq); \& my $bool = $backend\->fail_job( \& $job_id, $retries, {whatever => \*(AqSomething went wrong!\*(Aq}); .Ve .PP Transition from \f(CW\*(C`active\*(C'\fR to \f(CW\*(C`failed\*(C'\fR state, and if there are attempts remaining, transition back to \f(CW\*(C`inactive\*(C'\fR with a delay based on \&\*(L"backoff\*(R" in Minion. Meant to be overloaded in a subclass. .SS "finish_job" .IX Subsection "finish_job" .Vb 4 \& my $bool = $backend\->finish_job($job_id, $retries); \& my $bool = $backend\->finish_job($job_id, $retries, \*(AqAll went well!\*(Aq); \& my $bool = $backend\->finish_job( \& $job_id, $retries, {whatever => \*(AqAll went well!\*(Aq}); .Ve .PP Transition from \f(CW\*(C`active\*(C'\fR to \f(CW\*(C`finished\*(C'\fR state. Meant to be overloaded in a subclass. .SS "job_info" .IX Subsection "job_info" .Vb 1 \& my $job_info = $backend\->job_info($job_id); .Ve .PP Get information about a job, or return \f(CW\*(C`undef\*(C'\fR if job does not exist. Meant to be overloaded in a subclass. .PP .Vb 2 \& # Check job state \& my $state = $backend\->job_info($job_id)\->{state}; \& \& # Get job result \& my $result = $backend\->job_info($job_id)\->{result}; .Ve .PP These fields are currently available: .IP "args" 2 .IX Item "args" .Vb 1 \& args => [\*(Aqfoo\*(Aq, \*(Aqbar\*(Aq] .Ve .Sp Job arguments. .IP "attempts" 2 .IX Item "attempts" .Vb 1 \& attempts => 25 .Ve .Sp Number of times performing this job will be attempted. .IP "children" 2 .IX Item "children" .Vb 1 \& children => [\*(Aq10026\*(Aq, \*(Aq10027\*(Aq, \*(Aq10028\*(Aq] .Ve .Sp Jobs depending on this job. .IP "created" 2 .IX Item "created" .Vb 1 \& created => 784111777 .Ve .Sp Epoch time job was created. .IP "delayed" 2 .IX Item "delayed" .Vb 1 \& delayed => 784111777 .Ve .Sp Epoch time job was delayed to. .IP "finished" 2 .IX Item "finished" .Vb 1 \& finished => 784111777 .Ve .Sp Epoch time job was finished. .IP "parents" 2 .IX Item "parents" .Vb 1 \& parents => [\*(Aq10023\*(Aq, \*(Aq10024\*(Aq, \*(Aq10025\*(Aq] .Ve .Sp Jobs this job depends on. .IP "priority" 2 .IX Item "priority" .Vb 1 \& priority => 3 .Ve .Sp Job priority. .IP "queue" 2 .IX Item "queue" .Vb 1 \& queue => \*(Aqimportant\*(Aq .Ve .Sp Queue name. .IP "result" 2 .IX Item "result" .Vb 1 \& result => \*(AqAll went well!\*(Aq .Ve .Sp Job result. .IP "retried" 2 .IX Item "retried" .Vb 1 \& retried => 784111777 .Ve .Sp Epoch time job has been retried. .IP "retries" 2 .IX Item "retries" .Vb 1 \& retries => 3 .Ve .Sp Number of times job has been retried. .IP "started" 2 .IX Item "started" .Vb 1 \& started => 784111777 .Ve .Sp Epoch time job was started. .IP "state" 2 .IX Item "state" .Vb 1 \& state => \*(Aqinactive\*(Aq .Ve .Sp Current job state, usually \f(CW\*(C`active\*(C'\fR, \f(CW\*(C`failed\*(C'\fR, \f(CW\*(C`finished\*(C'\fR or \f(CW\*(C`inactive\*(C'\fR. .IP "task" 2 .IX Item "task" .Vb 1 \& task => \*(Aqfoo\*(Aq .Ve .Sp Task name. .IP "worker" 2 .IX Item "worker" .Vb 1 \& worker => \*(Aq154\*(Aq .Ve .Sp Id of worker that is processing the job. .SS "list_jobs" .IX Subsection "list_jobs" .Vb 2 \& my $batch = $backend\->list_jobs($offset, $limit); \& my $batch = $backend\->list_jobs($offset, $limit, {state => \*(Aqinactive\*(Aq}); .Ve .PP Returns the same information as \*(L"job_info\*(R" but in batches. Meant to be overloaded in a subclass. .PP These options are currently available: .IP "queue" 2 .IX Item "queue" .Vb 1 \& queue => \*(Aqimportant\*(Aq .Ve .Sp List only jobs in this queue. .IP "state" 2 .IX Item "state" .Vb 1 \& state => \*(Aqinactive\*(Aq .Ve .Sp List only jobs in this state. .IP "task" 2 .IX Item "task" .Vb 1 \& task => \*(Aqtest\*(Aq .Ve .Sp List only jobs for this task. .SS "list_workers" .IX Subsection "list_workers" .Vb 1 \& my $batch = $backend\->list_workers($offset, $limit); .Ve .PP Returns the same information as \*(L"worker_info\*(R" but in batches. Meant to be overloaded in a subclass. .SS "receive" .IX Subsection "receive" .Vb 1 \& my $commands = $backend\->receive($worker_id); .Ve .PP Receive remote control commands for worker. .SS "register_worker" .IX Subsection "register_worker" .Vb 2 \& my $worker_id = $backend\->register_worker; \& my $worker_id = $backend\->register_worker($worker_id); .Ve .PP Register worker or send heartbeat to show that this worker is still alive. Meant to be overloaded in a subclass. .SS "remove_job" .IX Subsection "remove_job" .Vb 1 \& my $bool = $backend\->remove_job($job_id); .Ve .PP Remove \f(CW\*(C`failed\*(C'\fR, \f(CW\*(C`finished\*(C'\fR or \f(CW\*(C`inactive\*(C'\fR job from queue. Meant to be overloaded in a subclass. .SS "repair" .IX Subsection "repair" .Vb 1 \& $backend\->repair; .Ve .PP Repair worker registry and job queue if necessary. Meant to be overloaded in a subclass. .SS "reset" .IX Subsection "reset" .Vb 1 \& $backend\->reset; .Ve .PP Reset job queue. Meant to be overloaded in a subclass. .SS "retry_job" .IX Subsection "retry_job" .Vb 2 \& my $bool = $backend\->retry_job($job_id, $retries); \& my $bool = $backend\->retry_job($job_id, $retries, {delay => 10}); .Ve .PP Transition from \f(CW\*(C`failed\*(C'\fR or \f(CW\*(C`finished\*(C'\fR state back to \f(CW\*(C`inactive\*(C'\fR, already \&\f(CW\*(C`inactive\*(C'\fR jobs may also be retried to change options. Meant to be overloaded in a subclass. .PP These options are currently available: .IP "delay" 2 .IX Item "delay" .Vb 1 \& delay => 10 .Ve .Sp Delay job for this many seconds (from now). .IP "priority" 2 .IX Item "priority" .Vb 1 \& priority => 5 .Ve .Sp Job priority. .IP "queue" 2 .IX Item "queue" .Vb 1 \& queue => \*(Aqimportant\*(Aq .Ve .Sp Queue to put job in. .SS "stats" .IX Subsection "stats" .Vb 1 \& my $stats = $backend\->stats; .Ve .PP Get statistics for jobs and workers. Meant to be overloaded in a subclass. .PP These fields are currently available: .IP "active_jobs" 2 .IX Item "active_jobs" .Vb 1 \& active_jobs => 100 .Ve .Sp Number of jobs in \f(CW\*(C`active\*(C'\fR state. .IP "active_workers" 2 .IX Item "active_workers" .Vb 1 \& active_workers => 100 .Ve .Sp Number of workers that are currently processing a job. .IP "delayed_jobs" 2 .IX Item "delayed_jobs" .Vb 1 \& delayed_jobs => 100 .Ve .Sp Number of jobs in \f(CW\*(C`inactive\*(C'\fR state that are scheduled to run at specific time in the future or have unresolved dependencies. Note that this field is \&\s-1EXPERIMENTAL\s0 and might change without warning! .IP "failed_jobs" 2 .IX Item "failed_jobs" .Vb 1 \& failed_jobs => 100 .Ve .Sp Number of jobs in \f(CW\*(C`failed\*(C'\fR state. .IP "finished_jobs" 2 .IX Item "finished_jobs" .Vb 1 \& finished_jobs => 100 .Ve .Sp Number of jobs in \f(CW\*(C`finished\*(C'\fR state. .IP "inactive_jobs" 2 .IX Item "inactive_jobs" .Vb 1 \& inactive_jobs => 100 .Ve .Sp Number of jobs in \f(CW\*(C`inactive\*(C'\fR state. .IP "inactive_workers" 2 .IX Item "inactive_workers" .Vb 1 \& inactive_workers => 100 .Ve .Sp Number of workers that are currently not processing a job. .SS "unregister_worker" .IX Subsection "unregister_worker" .Vb 1 \& $backend\->unregister_worker($worker_id); .Ve .PP Unregister worker. Meant to be overloaded in a subclass. .SS "worker_info" .IX Subsection "worker_info" .Vb 1 \& my $worker_info = $backend\->worker_info($worker_id); .Ve .PP Get information about a worker, or return \f(CW\*(C`undef\*(C'\fR if worker does not exist. Meant to be overloaded in a subclass. .PP .Vb 2 \& # Check worker host \& my $host = $backend\->worker_info($worker_id)\->{host}; .Ve .PP These fields are currently available: .IP "host" 2 .IX Item "host" .Vb 1 \& host => \*(Aqlocalhost\*(Aq .Ve .Sp Worker host. .IP "jobs" 2 .IX Item "jobs" .Vb 1 \& jobs => [\*(Aq10023\*(Aq, \*(Aq10024\*(Aq, \*(Aq10025\*(Aq, \*(Aq10029\*(Aq] .Ve .Sp Ids of jobs the worker is currently processing. .IP "notified" 2 .IX Item "notified" .Vb 1 \& notified => 784111777 .Ve .Sp Epoch time worker sent the last heartbeat. .IP "pid" 2 .IX Item "pid" .Vb 1 \& pid => 12345 .Ve .Sp Process id of worker. .IP "started" 2 .IX Item "started" .Vb 1 \& started => 784111777 .Ve .Sp Epoch time worker was started. .SH "SEE ALSO" .IX Header "SEE ALSO" Minion, Mojolicious::Guides, .