-
Notifications
You must be signed in to change notification settings - Fork 27
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
Avoid obtaining Vertx from CDI #109
Conversation
This is needed because the VertxVaultClient can potentially be used inside a Synthetic bean and in such cases obtaining Vertx which is itself a synthetic bean is not possible Fixes: quarkiverse#78
@geoand I'm not sure this does exactly what the previous code was doing. I need to look at this more in depth and report back. The goal with Shared/Private is to ensure the system provided VertX (aka Shared) is used whenever it is available but for config related queries we might need to create a temporary (aka Private) VertX instance to query Vault before the system provides one. |
I'm realizing that |
Right, that's also what my PR does, doesn't it? |
This is a |
Okay, so how would you like to handle it? |
I think the following works. Basically the same code just uses @Produces
@Dependent
public static VertxVaultClient createSharedVaultClient() {
Annotation clientType;
if (VertxRecorder.getVertx() != null) {
clientType = Shared.Literal.INSTANCE;
} else {
clientType = Private.Literal.INSTANCE;
}
return Arc.container().select(VertxVaultClient.class, clientType).get();
} public SharedVertxVaultClient(VaultConfigHolder vaultConfigHolder, TlsConfig tlsConfig) {
super(vaultConfigHolder.getVaultBootstrapConfig().url.orElseThrow(() -> new VaultException("no vault url provided")),
vaultConfigHolder.getVaultBootstrapConfig().enterprise.namespace,
vaultConfigHolder.getVaultBootstrapConfig().readTimeout);
Vertx vertx = Vertx.newInstance(VertxRecorder.getVertx());
this.webClient.set(createHttpClient(vertx, vaultConfigHolder.getVaultBootstrapConfig(), tlsConfig));
} |
I tested this locally. I can push the changes to the PR branch. |
Sounds good to me |
This is needed because the VertxVaultClient can potentially be used inside a Synthetic bean and in such cases
obtaining Vertx which is itself a synthetic bean is not possible
Fixes: #78