NAME
Minion::Worker - Minion worker
SYNOPSIS
use Minion::Worker;
my $worker = Minion::Worker->new(minion => $minion);
DESCRIPTION
Minion::Worker performs jobs for Minion.
EVENTS
Minion::Worker inherits all events from Mojo::EventEmitter and can emit the following new ones.
dequeue
$worker->on(dequeue => sub {
my ($worker, $job) = @_;
...
});
Emitted when a job has been dequeued.
$worker->on(dequeue => sub {
my ($worker, $job) = @_;
my $oid = $job->id;
say "Job $oid has been dequeued.";
});
ATTRIBUTES
Minion::Worker implements the following attributes.
id
my $oid = $worker->id;
$worker = $worker->id($oid);
Worker id.
minion
my $minion = $worker->minion;
$worker = $worker->minion(Minion->new);
Minion object this worker belongs to.
number
my $num = $worker->number;
$worker = $worker->number(5);
Number of this worker, unique per process.
METHODS
Minion::Worker inherits all methods from Mojo::EventEmitter and implements the following new ones.
dequeue
my $job = $worker->dequeue;
Dequeue Minion::Job object and transition from inactive
to active
state or return undef
if queue was empty.
register
$worker = $worker->register;
Register worker.
started
my $epoch = $worker->started;
Time this worker was started in floating seconds since the epoch.
unregister
$worker = $worker->unregister;
Unregister worker.