Skip to content

Commit

Permalink
Don't use VertxRecorder to get Vertx instance
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Sep 14, 2023
1 parent 5ddf25e commit f3795f8
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import jakarta.annotation.PreDestroy;
import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;

import io.quarkus.arc.Arc;
import io.quarkus.runtime.TlsConfig;
import io.quarkus.vault.VaultException;
import io.quarkus.vault.runtime.VaultConfigHolder;
import io.quarkus.vertx.runtime.VertxRecorder;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.ext.web.client.WebClient;

Expand All @@ -24,9 +24,9 @@ public class SharedVertxVaultClient extends VertxVaultClient {

@Produces
@Dependent
public static VertxVaultClient createSharedVaultClient() {
public static VertxVaultClient createSharedVaultClient(Instance<Vertx> vertx) {
Annotation clientType;
if (VertxRecorder.getVertx() != null) {
if (vertx.isResolvable()) {
clientType = Shared.Literal.INSTANCE;
} else {
clientType = Private.Literal.INSTANCE;
Expand All @@ -36,11 +36,11 @@ public static VertxVaultClient createSharedVaultClient() {

private final AtomicReference<WebClient> webClient = new AtomicReference<>();

public SharedVertxVaultClient(VaultConfigHolder vaultConfigHolder, TlsConfig tlsConfig) {
public SharedVertxVaultClient(VaultConfigHolder vaultConfigHolder, Vertx quarkusMutinyVertx, TlsConfig tlsConfig) {
super(vaultConfigHolder.getVaultRuntimeConfig().url().orElseThrow(() -> new VaultException("no vault url provided")),
vaultConfigHolder.getVaultRuntimeConfig().enterprise().namespace(),
vaultConfigHolder.getVaultRuntimeConfig().readTimeout());
Vertx vertx = Vertx.newInstance(VertxRecorder.getVertx());
Vertx vertx = Vertx.newInstance(quarkusMutinyVertx.getDelegate());
this.webClient.set(createHttpClient(vertx, vaultConfigHolder.getVaultRuntimeConfig(), tlsConfig));
}

Expand Down

0 comments on commit f3795f8

Please sign in to comment.