.\" 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::Worker 3pm" .TH Minion::Worker 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::Worker \- Minion worker .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Minion::Worker; \& \& my $worker = Minion::Worker\->new(minion => $minion); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Minion::Worker performs jobs for Minion. .SH "EVENTS" .IX Header "EVENTS" Minion::Worker inherits all events from Mojo::EventEmitter and can emit the following new ones. .SS "dequeue" .IX Subsection "dequeue" .Vb 4 \& $worker\->on(dequeue => sub { \& my ($worker, $job) = @_; \& ... \& }); .Ve .PP Emitted in the worker process after a job has been dequeued. .PP .Vb 5 \& $worker\->on(dequeue => sub { \& my ($worker, $job) = @_; \& my $id = $job\->id; \& say "Job $id has been dequeued."; \& }); .Ve .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Minion::Worker implements the following attributes. .SS "commands" .IX Subsection "commands" .Vb 2 \& my $commands = $worker\->commands; \& $worker = $worker\->commands({jobs => sub {...}}); .Ve .PP Registered worker remote control commands. .SS "id" .IX Subsection "id" .Vb 2 \& my $id = $worker\->id; \& $worker = $worker\->id($id); .Ve .PP Worker id. .SS "minion" .IX Subsection "minion" .Vb 2 \& my $minion = $worker\->minion; \& $worker = $worker\->minion(Minion\->new); .Ve .PP Minion object this worker belongs to. .SH "METHODS" .IX Header "METHODS" Minion::Worker inherits all methods from Mojo::EventEmitter and implements the following new ones. .SS "add_command" .IX Subsection "add_command" .Vb 1 \& $worker = $worker\->add_command(jobs => sub {...}); .Ve .PP Register a worker remote control command. .PP .Vb 4 \& $worker\->add_command(foo => sub { \& my ($worker, @args) = @_; \& ... \& }); .Ve .SS "dequeue" .IX Subsection "dequeue" .Vb 2 \& my $job = $worker\->dequeue(0.5); \& my $job = $worker\->dequeue(0.5 => {queues => [\*(Aqimportant\*(Aq]}); .Ve .PP Wait a given amount of time in seconds for a job, dequeue Minion::Job object 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. .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. .SS "info" .IX Subsection "info" .Vb 1 \& my $info = $worker\->info; .Ve .PP Get worker information. .PP .Vb 2 \& # Check worker host \& my $host = $worker\->info\->{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. .SS "process_commands" .IX Subsection "process_commands" .Vb 1 \& $worker = $worker\->process_commands; .Ve .PP Process worker remote control commands. .SS "register" .IX Subsection "register" .Vb 1 \& $worker = $worker\->register; .Ve .PP Register worker or send heartbeat to show that this worker is still alive. .SS "unregister" .IX Subsection "unregister" .Vb 1 \& $worker = $worker\->unregister; .Ve .PP Unregister worker. .SH "SEE ALSO" .IX Header "SEE ALSO" Minion, Mojolicious::Guides, .