Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add backend-agnostic connection check #135

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Minion/Backend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sub list_locks { croak 'Method "list_locks" not implemented by subclass'
sub list_workers { croak 'Method "list_workers" not implemented by subclass' }
sub lock { croak 'Method "lock" not implemented by subclass' }
sub note { croak 'Method "note" not implemented by subclass' }
sub ping { croak 'Method "ping" not implemented by subclass' }
sub receive { croak 'Method "receive" not implemented by subclass' }
sub register_worker { croak 'Method "register_worker" not implemented by subclass' }
sub remove_job { croak 'Method "remove_job" not implemented by subclass' }
Expand Down Expand Up @@ -57,6 +58,7 @@ Minion::Backend - Backend base class
sub list_workers {...}
sub lock {...}
sub note {...}
sub ping {...}
sub receive {...}
sub register_worker {...}
sub remove_job {...}
Expand Down Expand Up @@ -616,6 +618,12 @@ Number of shared locks with the same name that can be active at the same time, d
Change one or more metadata fields for a job. Setting a value to C<undef> will remove the field. Meant to be overloaded
in a subclass.

=head2 ping

my $bool = $backend->ping;

Shortcut to underlying database object C<ping> method, useful for avoiding connexion timeout.

=head2 receive

my $commands = $backend->receive($worker_id);
Expand Down
5 changes: 5 additions & 0 deletions lib/Minion/Backend/Pg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ sub broadcast {
{json => [[$command, @$args]]}, $ids)->rows;
}

sub ping {
my ($self) = @_;
return $self->pg->db->ping();
}

sub dequeue {
my ($self, $id, $wait, $options) = @_;

Expand Down