-
-
Save tsucchi/eee4f18e254634c53a485f8b15f066e4 to your computer and use it in GitHub Desktop.
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
sub _try { | |
my ($self, $id, $options) = @_; | |
my @binds = ( | |
$options->{id}, | |
$options->{queues} || ['default'], | |
[keys %{$self->minion->tasks}] | |
); | |
return $self->pg->db->query( | |
"update minion_jobs | |
set started = now() | |
, state = 'active' | |
, worker = ? | |
where id = ( | |
select id from minion_jobs as j | |
where delayed <= now() | |
and id = coalesce(?, id) | |
and (parents = '{}' or not exists ( | |
select 1 from minion_jobs | |
where id = any (j.parents) | |
and state in ('inactive', 'active', 'failed') | |
)) | |
and queue = any (?) | |
and state = 'inactive' | |
and task = any (?) | |
order by priority desc, random_pickup | |
limit 1 | |
for update skip locked | |
) | |
returning id, args, retries, task", $id, @binds | |
)->expand->hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment