add backend-agnostic connection check#135
add backend-agnostic connection check#135guillomovitch wants to merge 2 commits intomojolicious:mainfrom
Conversation
This is useful for avoiding database connection getting idle.
|
I don't like that this requires changes in every single backend. Based on that fact i'm voting 👎 . |
|
Could it also implement |
|
The whole idea of having a |
|
And it's not like |
|
The default minion setup, at least when used with minion plugin, is to establish a single persistent network connection with the backend, as long a the application is running. Ensuring this connection stays functional is mandatory when intermediate network equipments automatically cut off idle connections. So, the actual need is just to make easier to implement a keepalive mechanism to match this strategy. Actually, small differences between backends (each one use a different property to store its database object) require the application to handle each backend differently, ie: With this small abstraction layer added to minion, this would turn to: This keepalive mechanism would also be a useful addition to @jberger I may indeed add a |
|
I get what you want to ultimately achieve, but the implementation makes no sense in a job queue API. Just look at the method description |
|
I just re-used the name and description of Alternatives solutions:
The first solution is basically making desencapsulation easier, the second one seems a better idea, but I'm unconfortable with the idea of private methods implemented in a child class, and used from a parent class. |
|
Last commit provides better documentation, in order to adress this comment. |
|
I'd rather make it easier to write backend specific code. Like with a |
|
The point here is precisely to avoid having to write backend-specific code, as the problem does not come from the backend. A
my $handle = $app->minion->backend->handle;
if ($handle->can('ping')) {
Mojo::IOLoop->recurring($delay => sub ($loop) {
$handle->ping;
});
}
|
That doesn't work because not all backends are DBI based. I guess then we can't do anything here. |
Summary
Each minion class backend uses a different attribute for its database connection object ('pg' for postgres backend, 'mysql' for mysql backend, etc). This makes low-level operations implementation-dependant.
Motivation
The change allows to send regular traffic to the backend, in order to avoid the database connection being closed for timeout, in a backend-agnostic way.
References
See discussion #2229.