-
-
Save anonymous/8b9c5fa349c97d015ef4 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
diff --git a/lib/Minion/Backend/Pg.pm b/lib/Minion/Backend/Pg.pm | |
index 1f16402..00060a9 100644 | |
--- a/lib/Minion/Backend/Pg.pm | |
+++ b/lib/Minion/Backend/Pg.pm | |
@@ -85,12 +85,12 @@ sub new { | |
sub register_worker { | |
my ($self, $id) = @_; | |
- my $sql | |
- = 'update minion_workers set notified = now() where id = ? returning 1'; | |
- return $id if $id && $self->pg->db->query($sql, $id)->rows; | |
- | |
- $sql = 'insert into minion_workers (host, pid) values (?, ?) returning id'; | |
- return $self->pg->db->query($sql, hostname, $$)->hash->{id}; | |
+ return shift->pg->db->query( | |
+ 'insert into minion_workers (id, host, pid) values (?, ?, ?) | |
+ on conflict(id) do update set notified = now() | |
+ returning id | |
+ ', $id || $DBD::Pg::DBDPG_DEFAULT, $self->{host} //= hostname, $$ | |
+ )->hash->{id}; | |
} | |
sub remove_job { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment