I want to use Minion <https://metacpan.org/pod/Minion> to process many
excels from users upload. I read the source code of Minion, but I don't
know how to parallel processing the job. I'm not use Mojolicious Framework.
I just want to use the job/worker feature in Minion.
#/usr/bin/perl
use Minion;
# Connect to backend
my $minion = Minion->new(Pg => 'postgresql://postgres@/test');
# Add tasks
$minion->add_task(something_slow => sub {
my ($job, @args) = @_;
sleep 2;
my $worker_num = $minion->stats->{inactive_workers};
my $idle_num = $minion->stats->{inactive_workers};
print "args: " . join(",", @args) . "\n";
print 'This is a background worker process.', "\n";
});
# Enqueue jobs
$minion->enqueue(something_slow => ['foo', 'bar']);
$minion->enqueue(something_slow => [1, 2, 3] => {priority => 5});
$minion->enqueue(something_slow => ['foo', 'bar2']);
my @jobs;
while ( 1 ) {
my $worker = $minion->worker;
my $job = $worker->register->dequeue(0);
last unless $job;
push @jobs, $job;
}
foreach my $job ( @jobs ) {
$job->perform()
}
This is my code.
I don't know how to add event loop.
Thank you
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.