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 $id = $job->id;
  say "Job $id has been dequeued.";
});

ATTRIBUTES

Minion::Worker implements the following attributes.

id

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

Worker id.

minion

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

Minion object this worker belongs to.

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.

info

my $info = $worker->info;

Get worker information.

register

$worker = $worker->register;

Register worker.

unregister

$worker = $worker->unregister;

Unregister worker.

SEE ALSO

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