Minion::Backend::File - File backend
use Minion::Backend::File; my $backend = Minion::Backend::File->new('/Users/sri/minion.data');
Minion::Backend::File is a highly portable file-based backend for Minion.
Minion::Backend::File inherits all attributes from Minion::Backend and implements the following new ones.
my $cb = $backend->deserialize; $backend = $backend->deserialize(sub {...});
A callback used to deserialize data, defaults to using Storable with gzip compression.
$backend->deserialize(sub { my $bytes = shift; return {}; });
my $file = $backend->file; $backend = $backend->file('/Users/sri/minion.data');
File all data is stored in.
my $cb = $backend->serialize; $backend = $backend->serialize(sub {...});
A callback used to serialize data, defaults to using Storable with gzip compression.
$backend->serialize(sub { my $hash = shift; return ''; });
Minion::Backend::File inherits all methods from Minion::Backend and implements the following new ones.
my $info = $backend->dequeue($worker_id, 0.5);
Wait for job, dequeue it and transition from inactive to active state or return undef if queue was empty.
inactive
active
undef
my $job_id = $backend->enqueue('foo'); my $job_id = $backend->enqueue(foo => [@args]); my $job_id = $backend->enqueue(foo => [@args] => {priority => 1});
Enqueue a new job with inactive state. You can also append a callback to perform operation non-blocking.
$backend->enqueue(foo => sub { my ($backend, $err, $job_id) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
my $bool = $backend->fail_job($job_id); my $bool = $backend->fail_job($job_id, 'Something went wrong!');
Transition from active to failed state.
failed
my $bool = $backend->finish_job($job_id);
Transition from active to finished state.
finished
my $info = $backend->job_info($job_id);
Get information about a job or return undef if job does not exist.
my $batch = $backend->list_jobs($skip, $limit);
Returns the same information as "job_info" but in batches.
my $batch = $backend->list_workers($skip, $limit);
Returns the same information as "worker_info" but in batches.
my $backend = Minion::Backend::File->new('/Users/sri/minion.data');
Construct a new Minion::Backend::File object.
my $worker_id = $backend->register_worker;
Register worker.
my $bool = $backend->remove_job($job_id);
Remove failed, finished or inactive job from queue.
$backend->repair;
Repair worker registry and job queue if necessary.
$backend->reset;
Reset job queue.
my $bool = $backend->retry_job($job_id);
Transition from failed or finished state back to inactive.
my $stats = $backend->stats;
Get statistics for jobs and workers.
$backend->unregister_worker($worker_id);
Unregister worker.
my $info = $backend->worker_info($worker_id);
Get information about a worker or return undef if worker does not exist.
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.