NAME

Minion::Job - Minion job

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 after this job transitioned to the failed state.

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

finished

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

Emitted after this job transitioned to the finished state.

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

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.

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!');

Transition from active to failed state.

finish

my $bool = $job->finish;

Transition from active to finished state.

info

my $info = $job->info;

Get job information.

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.

restart

my $bool = $job->restart;

Transition from failed or finished state back to inactive.

SEE ALSO

Minion, Mojolicious::Guides, http://mojolicio.us.