Created
October 25, 2016 08:34
-
-
Save brianmed/770ae233a258d8dd5d23317ec6c4bdf0 to your computer and use it in GitHub Desktop.
Very small minion retry example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
app->log->level("debug"); | |
plugin Minion => { SQLite => 'sqlite:minimal_minion.db' }; | |
app->minion->add_task(generate_image => sub { | |
my ($job, @args) = @_; | |
srand(); | |
my $rand = int(rand(10)); | |
app->log->info("$job rand: $rand"); | |
if (5 < $rand) { | |
app->log->info("$job retrying"); | |
$job->finish; | |
$job->retry({ delay => 5 }); | |
return; | |
} | |
app->log->info("$job done"); | |
$job->finish; | |
}); | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment