Skip to content

Instantly share code, notes, and snippets.

/enqueue.pl Secret

Created September 16, 2016 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fc6fcb9eb97359339e0b56141a43107d to your computer and use it in GitHub Desktop.
Save anonymous/fc6fcb9eb97359339e0b56141a43107d to your computer and use it in GitHub Desktop.
sub enqueue {
my ($self, $task, $args, $options) = (shift, shift, shift || [], shift || {});
my $db = $self->pg->db;
return $db->query(
"insert into minion_jobs
(args, attempts, delayed, parents, priority, queue, task)
values (?, ?, (now() + (interval '1 second' * ?)), ?, ?, ?, ?)
returning id", {json => $args}, $options->{attempts} // 1,
$options->{delay} // 0, $options->{parents} || [],
$options->{priority} // 0, $options->{queue} // 'default', $task
)->hash->{id};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment