Open ernestojpg opened 6 years ago
it looks like a good feature to provide
Cool, I will try to implement it soon.
@ernestojpg perhaps you can look at Vert.x HttpClient pool that is now reusable. If we could reuse it, it would be great and keep only a single pool to maintain
Hi @vietj , sorry for the delay in answering.
I'm not 100% sure, but yes, we could probably use the new http client pool for this service as well, but it would require a big refactoring of the "vertx-mysql-postgresql-client" service first (for using the new pool), and then implementing the reconnections logic in the new pool without breaking anything else. I don't know if I will have so much time :)
For now, I have implemented the change easily in the current pool, and I will try to implement the new pool in the future. Let me know what you think.
Regards.
@ernestojpg ok
Hi all!
It would be nice if the library could recover from temporary database outages, such as those which occur during a database restart or brief loss of network connectivity.
Because the underlying library from mauricio does not support this functionality yet, we could implement it easily in our
AsyncConnectionPool.createConnection()
method, just using a counter and Vert.x timers.I would create a couple of new configuration properties. For example:
maxConnectionRetries
connectionRetryDelay
When our
AsyncConnectionPool
attempts to acquire an open Connection and fails, it will retry up tomaxConnectionRetries
times, with a delay ofconnectionRetryDelay
between each attempt. If all attempts fail, any clients waiting for Connections from ourAsyncConnectionPool
will see an Exception, indicating that a Connection could not be acquired.For keeping full compatibility with the current code, I would set
maxConnectionRetries
to0
by default, that means that no reconnections will be done. If we setmaxConnectionRetries
to-1
ourAsyncConnectionPool
will attempt to acquire new Connections indefinitely.What do you think? If you are happy with that I can create a pull request with the changes.
Regards.