GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MINION::JOB (3)

.ds Aq ’

NAME

Minion::Job - Minion job

CONTENTS

SYNOPSIS



  use Minion::Job;

  my $job = Minion::Job->new(id => $id, minion => $minion, task => foo);



DESCRIPTION

Minion::Job is a container for Minion jobs.

EVENTS

Minion::Job inherits all events from Mojo::EventEmitter and can emit the following new ones.

    failed



  $job->on(failed => sub {
    my ($job, $err) = @_;
    ...
  });



Emitted in the worker process managing this job or the process performing it, after it has transitioned to the failed state.



  $job->on(failed => sub {
    my ($job, $err) = @_;
    say "Something went wrong: $err";
  });



    finished



  $job->on(finished => sub {
    my ($job, $result) = @_;
    ...
  });



Emitted in the worker process managing this job or the process performing it, after it has transitioned to the finished state.



  $job->on(finished => sub {
    my ($job, $result) = @_;
    my $id = $job->id;
    say "Job $id is finished.";
  });



    spawn



  $job->on(spawn => sub {
    my ($job, $pid) = @_;
    ...
  });



Emitted in the worker process managing this job, after a new process has been spawned for processing.



  $job->on(spawn => sub {
    my ($job, $pid) = @_;
    my $id = $job->id;
    say "Job $id running in process $pid";
  });



    start



  $job->on(start => sub {
    my $job = shift;
    ...
  });



Emitted in the process performing this job, after it has been spawned.



  $job->on(start => sub {
    my $job = shift;
    $0 = $job->id;
  });



ATTRIBUTES

Minion::Job implements the following attributes.

    args



  my $args = $job->args;
  $job     = $job->args([]);



Arguments passed to task.

    id



  my $id = $job->id;
  $job   = $job->id($id);



Job id.

    minion



  my $minion = $job->minion;
  $job       = $job->minion(Minion->new);



Minion object this job belongs to.

    retries



  my $retries = $job->retries;
  $job        = $job->retries(5);



Number of times job has been retried.

    task



  my $task = $job->task;
  $job     = $job->task(foo);



Task name.

METHODS

Minion::Job inherits all methods from Mojo::EventEmitter and implements the following new ones.

    app



  my $app = $job->app;



Get application from app in Minion.



  # Longer version
  my $app = $job->minion->app;



    fail



  my $bool = $job->fail;
  my $bool = $job->fail(Something went wrong!);
  my $bool = $job->fail({whatever => Something went wrong!});



Transition from active to failed state, and if there are attempts remaining, transition back to inactive with a delay based on backoff in Minion.

    finish



  my $bool = $job->finish;
  my $bool = $job->finish(All went well!);
  my $bool = $job->finish({whatever => All went well!});



Transition from active to finished state.

    info



  my $info = $job->info;



Get job information.



  # Check job state
  my $state = $job->info->{state};

  # Get job result
  my $result = $job->info->{result};



These fields are currently available:
args


  args => [foo, bar]



Job arguments.

attempts


  attempts => 25



Number of times performing this job will be attempted.

created


  created => 784111777



Time job was created.

delayed


  delayed => 784111777



Time job was delayed to.

finished


  finished => 784111777



Time job was finished.

priority


  priority => 3



Job priority.

queue


  queue => important



Queue name.

result


  result => All went well!



Job result.

retried


  retried => 784111777



Time job has been retried.

retries


  retries => 3



Number of times job has been retried.

started


  started => 784111777



Time job was started.

state


  state => inactive



Current job state, usually active, failed, finished or inactive.

task


  task => foo



Task name.

worker


  worker => 154



Id of worker that is processing the job.

    is_finished



  my $bool = $job->is_finished($pid);



Check if job performed with start is finished.

    perform



  $job->perform;



Perform job in new process and wait for it to finish.

    remove



  my $bool = $job->remove;



Remove failed, finished or inactive job from queue.

    retry



  my $bool = $job->retry;
  my $bool = $job->retry({delay => 10});



Transition from failed or finished state back to inactive, already inactive jobs may also be retried to change options.

These options are currently available:
delay


  delay => 10



Delay job for this many seconds (from now).

priority


  priority => 5



Job priority.

queue


  queue => important



Queue to put job in.

    start



  my $pid = $job->start;



Perform job in new process, but do not wait for it to finish.



  # Perform two jobs concurrently
  my $pid1 = $job1->start;
  my $pid2 = $job2->start;
  my ($first, $second);
  sleep 1
    until $first  ||= $job1->is_finished($pid1)
    and   $second ||= $job2->is_finished($pid2);



SEE ALSO

Minion, Mojolicious::Guides, <http://mojolicious.org>.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MINION::JOB (3) 2016-02-16

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.