Minion::Job(3)
π Minion::Job β the whole vibe π
okay bestie, welcome to Minion::Job (that's the Minion::Job(3) page from the User Contributed Perl Documentation, if you're keeping receipts) β it's a container for Minion jobs and honestly it's giving main character energy for your whole task pipeline β¨
β¨ NAME β¨
Minion::Job β a Minion job. that's it. that's the name. iconic π
πΈ SYNOPSIS πΈ
here's the whole setup, no cap:
package MyApp::Task::Foo;
use Mojo::Base 'Minion::Job', -signatures;
sub run ($self, @args) {
# Magic here! :)
}
see that # Magic here! :)? that's you. that's your moment. go off π§
π¦ DESCRIPTION π¦
Minion::Job is a container for Minion jobs. literally just a little box that holds one job and all its hopes and dreams π«Ά
π EVENTS π
Minion::Job inherits all events from Mojo::EventEmitter and can emit the following new ones. these are your little notification pings, bestie π
π cleanup
$job->on(cleanup => sub ($job) {
...
});
Emitted in the process performing this job right before the process will exit. like the last text before you go to sleep π
$job->on(cleanup => sub ($job) {
$job->app->log->debug("Process $$ is about to exit");
});
π failed
$job->on(failed => sub ($job, $err) {
...
});
Emitted in the worker process managing this job or the process performing it, after it has transitioned to the "failed" state. it's giving not-your-day π
$job->on(failed => sub ($job, $err) {
say "Something went wrong: $err";
});
π finish
$job->on(finish => sub ($job) {
...
});
Emitted in the process performing this job if the task was successful. slay β
$job->on(finish => sub ($job) {
my $id = $job->id;
my $task = $job->task;
$job->app->log->debug(qq{Job "$id" was performed with task "$task"});
});
π finished
$job->on(finished => sub ($job, $result) {
...
});
Emitted in the worker process managing this job or the process performing it, after it has transitioned to the "finished" state. she's done, she's healed, periodt π
$job->on(finished => sub ($job, $result) {
my $id = $job->id;
say "Job $id is finished.";
});
π reap
$job->on(reap => sub ($job, $pid) {
...
});
Emitted in the worker process managing this job, after the process performing it has exited. rip bozo (affectionate) π
$job->on(reap => sub ($job, $pid) {
my $id = $job->id;
say "Job $id ran in process $pid";
});
π spawn
$job->on(spawn => sub ($job, $pid) {
...
});
Emitted in the worker process managing this job, after a new process has been spawned for processing. baby process is born π£
$job->on(spawn => sub ($job, $pid) {
my $id = $job->id;
say "Job $id running in process $pid";
});
π start
$job->on(start => sub ($job) {
...
});
Emitted in the process performing this job, after it has been spawned. the way that this is literally the opening scene of the job's life π
$job->on(start => sub ($job) {
$0 = $job->id;
});
π ATTRIBUTES π
Minion::Job implements the following attributes. these are the little properties she carries around in her bag π
π args
my $args = $job->args;
$job = $job->args([]);
Arguments passed to task. the receipts, the lore π§Ύ
π id
my $id = $job->id;
$job = $job->id($id);
Job id. her name tag π
π minion
my $minion = $job->minion;
$job = $job->minion(Minion->new);
Minion object this job belongs to. her home base π
π retries
my $retries = $job->retries;
$job = $job->retries(5);
Number of times job has been retried. how many second chances she's gotten π
π task
my $task = $job->task;
$job = $job->task('foo');
Task name. what she's actually here to do β¨
π₯ METHODS π₯
Minion::Job inherits all methods from Mojo::EventEmitter and implements the following new ones. buckle up buttercup, this is the long section π€
π app
my $app = $job->app;
Get application from "app" in Minion. also here's the long version, iykyk:
# Longer version
my $app = $job->minion->app;
π execute
my $err = $job->execute;
Perform job in this process and return "undef" if the task was successful or an exception otherwise. Note that this method should only be used to implement custom workers.
# Perform job in foreground
if (my $err = $job->execute) { $job->fail($err) }
else { $job->finish }
π 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 with or without a result, and if there are attempts remaining, transition back to "inactive" with a delay based on "backoff" in Minion. she's not down bad, she's just resting π
π 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 with or without a result. ate and left no crumbs π
π info
my $info = $job->info;
Get job information. the whole gossip file π
# Check job state
my $state = $job->info->{state};
# Get job metadata
my $progress = $job->info->{notes}{progress};
# 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.childrenβchildren => ['10026', '10027', '10028']β Jobs depending on this job.createdβcreated => 784111777β Epoch time job was created.delayedβdelayed => 784111777β Epoch time job was delayed to.expiresβexpires => 784111777β Epoch time job is valid until before it expires.finishedβfinished => 784111777β Epoch time job was finished.laxβlax => 0β Existing jobs this job depends on may also have failed to allow for it to be processed.notesβnotes => {foo => 'bar', baz => [1, 2, 3]}β Hash reference with arbitrary metadata for this job.parentsβparents => ['10023', '10024', '10025']β Jobs this job depends on.priorityβpriority => 3β Job priority.queueβqueue => 'important'β Queue name.resultβresult => 'All went well!'β Job result.retriedβretried => 784111777β Epoch time job has been retried.retriesβretries => 3β Number of times job has been retried.startedβstarted => 784111777β Epoch time job was started.stateβstate => 'inactive'β Current job state, usually"active","failed","finished"or"inactive".taskβtask => 'foo'β Task name.timeβtime => 784111777β Server time.workerβworker => '154'β Id of worker that is processing the job.
π is_finished
my $bool = $job->is_finished;
Check if job performed with "start" is finished. Note that this method should only be used to implement custom workers.
π kill
$job->kill('INT');
Send a signal to job performed with "start". Note that this method should only be used to implement custom workers. it's giving "we need to talk" π¬
π note
my $bool = $job->note(mojo => 'rocks', minion => 'too');
Change one or more metadata fields for this job. Setting a value to "undef" will remove the field. The new values will get serialized by "backend" in Minion (often with Mojo::JSON), so you shouldn't send objects and be careful with binary data, nested data structures with hash and array references are fine though.
fr fr on the binary data thing, bestie β don't do it, it's not worth the drama π
# Share progress information
$job->note(progress => 95);
# Share stats
$job->note(stats => {utime => '0.012628', stime => '0.002429'});
π parents
my $parents = $job->parents;
Return a Mojo::Collection object containing all jobs this job depends on as Minion::Job objects. her ancestors, her lineage π
# Check parent state
for my $parent ($job->parents->each) {
my $info = $parent->info;
say "$info->{id}: $info->{state}";
}
π perform
$job->perform;
Perform job in new process and wait for it to finish. Note that this method should only be used to implement custom workers.
π pid
my $pid = $job->pid;
Process id of the process spawned by "start" if available. Note that this method should only be used to implement custom workers.
π remove
my $bool = $job->remove;
Remove "failed", "finished" or "inactive" job from queue. she's out, she's gone, blocked π«
π retry
my $bool = $job->retry;
my $bool = $job->retry({delay => 10});
Transition job back to "inactive" state, already "inactive" jobs may also be retried to change options. second chance era π«Ά
These options are currently available:
attemptsβattempts => 25β Number of times performing this job will be attempted.delayβdelay => 10β Delay job for this many seconds (from now), defaults to0.expireβexpire => 300β Job is valid for this many seconds (from now) before it expires.laxβlax => 1β Existing jobs this job depends on may also have transitioned to the"failed"state to allow for it to be processed, defaults to"false".parentsβparents => [$id1, $id2, $id3]β Jobs this job depends on.priorityβpriority => 5β Job priority.queueβqueue => 'important'β Queue to put job in.
π run
$job->run(@args);
Task to perform by this job. Meant to be overloaded in a subclass to create a custom task class.
β οΈ Note that this method is EXPERIMENTAL and might change without warning! β οΈ
like she said what she said but she might change her mind, no cap π
π start
$job = $job->start;
Perform job in new process, but do not wait for it to finish. Note that this method should only be used to implement custom workers.
# Perform two jobs concurrently
$job1->start;
$job2->start;
my ($first, $second);
sleep 1
until $first ||= $job1->is_finished and $second ||= $job2->is_finished;
multitasking queen behavior πΈ
π stop
$job->stop;
Stop job performed with "start" immediately. Note that this method should only be used to implement custom workers. abrupt but necessary, we've all been there π
π SEE ALSO π
go read these too, bestie, they're the extended universe:
- Minion
- Minion::Guide
- <https://minion.pm>
- Mojolicious::Guides
- <https://mojolicious.org>
and that's the whole page!! πβ¨ππ¦πΈπ
π«Ά this beauty ships as perl v5.42.0, dated 2026-01-17, and it's the Minion::Job(3) manpage β so go forth and run your tasks, you absolute icon ππ
π¦ where this page comes from
- fedora 44: perl-Minion 11.0-2.fc44 Β· Artistic-2.0 AND CC-BY-SA-4.0 AND MIT AND ISC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms