Minion::Job - Minion job
use Minion::Job; my $job = Minion::Job->new(id => $id, minion => $minion, task => 'foo');
Minion::Job is a container for Minion jobs.
Minion::Job inherits all events from Mojo::EventEmitter and can emit the following new ones.
$job->on(failed => sub { my ($job, $err) = @_; ... });
Emitted after this job transitioned to the failed state.
failed
$job->on(failed => sub { my ($job, $err) = @_; say "Something went wrong: $err"; });
$job->on(finished => sub { my $job = shift; ... });
Emitted after this job transitioned to the finished state.
finished
$job->on(finished => sub { my $job = shift; my $id = $job->id; say "Job $id is finished."; });
$job->on(spawn => sub { my ($job, $pid) = @_; ... });
Emitted after a process has been spawned to process this job.
$job->on(spawn => sub { my ($job, $pid) = @_; my $id = $job->id; say "Job $id running in process $pid"; });
Minion::Job implements the following attributes.
my $args = $job->args; $job = $job->args([]);
Arguments passed to task.
my $id = $job->id; $job = $job->id($id);
Job id.
my $minion = $job->minion; $job = $job->minion(Minion->new);
Minion object this job belongs to.
my $task = $job->task; $job = $job->task('foo');
Task name.
Minion::Job inherits all methods from Mojo::EventEmitter and implements the following new ones.
my $app = $job->app;
Get application from "app" in Minion.
# Longer version my $app = $job->minion->app;
my $bool = $job->fail; my $bool = $job->fail('Something went wrong!');
Transition from active to failed state.
active
my $bool = $job->finish;
Transition from active to finished state.
my $info = $job->info;
Get job information.
$job->perform;
Perform job in new process and wait for it to finish.
my $bool = $job->remove;
Remove failed, finished or inactive job from queue.
inactive
my $bool = $job->retry;
Transition from failed or finished state back to inactive.
Minion, Mojolicious::Guides, http://mojolicio.us.
To install Minion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Minion
CPAN shell
perl -MCPAN -e shell install Minion
For more information on module installation, please visit the detailed CPAN module installation guide.