Expose Hikari DataSources in Beans to support password rotation #1398
Labels
info: workaround available
A workaround is available for the issue
type: improvement
A minor improvement to an existing feature
Uh oh!
There was an error while loading. Please reload this page.
Feature description
Problem
Currently the DataSource's are encapsulated inside the
DatasourceFactory
class (see https://github.com/micronaut-projects/micronaut-sql/blob/5.7.x/jdbc-hikari/src/main/java/io/micronaut/configuration/jdbc/hikari/DatasourceFactory.java). This makes it impossible to access the datasource without reflection.I would like to access the DataSource instances to rotate passwords without affecting the service availability.
Feature idea
Ideally I would like to simply get the "DataSource" and change things directly in there:
Workaround (using reflection)
As an alternative I am working with the following workaround (using reflection):
Please let me know if there is a better workaround.
How does Spring work (probably the best solution)
This is something kindof supported by Spring:
Basically you can override the
HikariUrlDataSource
class with any custom classname using theapplication.properties
. This is something that is not supported either by Micronaut. It is quite a clean solution with the disadvantage thatgetPassword
is called for each connection. It could be worked around using a memory cache or lazy variables.The text was updated successfully, but these errors were encountered: