From 529bbfa1a817234beb47b5f8e7ca4194c586eb71 Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Wed, 14 Jun 2023 18:05:12 +0300 Subject: [PATCH] Deferred token retrieval to scheduler --- .../io/scalecube/security/vault/VaultClientTokenSupplier.java | 2 ++ .../io/scalecube/security/vault/VaultServiceTokenSupplier.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/vault/src/main/java/io/scalecube/security/vault/VaultClientTokenSupplier.java b/vault/src/main/java/io/scalecube/security/vault/VaultClientTokenSupplier.java index 1e40dcb..d4b080b 100644 --- a/vault/src/main/java/io/scalecube/security/vault/VaultClientTokenSupplier.java +++ b/vault/src/main/java/io/scalecube/security/vault/VaultClientTokenSupplier.java @@ -12,6 +12,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; public final class VaultClientTokenSupplier { @@ -87,6 +88,7 @@ public VaultClientTokenSupplier vaultRole(String vaultRole) { public Mono getToken() { return Mono.fromRunnable(this::validate) .then(Mono.fromCallable(this::getToken0)) + .subscribeOn(Schedulers.boundedElastic()) .doOnSuccess(s -> LOGGER.debug("[getToken][success] result: {}", mask(s))) .doOnError(th -> LOGGER.error("[getToken][error] cause: {}", th.toString())); } diff --git a/vault/src/main/java/io/scalecube/security/vault/VaultServiceTokenSupplier.java b/vault/src/main/java/io/scalecube/security/vault/VaultServiceTokenSupplier.java index 62c1d0b..c7ba25e 100644 --- a/vault/src/main/java/io/scalecube/security/vault/VaultServiceTokenSupplier.java +++ b/vault/src/main/java/io/scalecube/security/vault/VaultServiceTokenSupplier.java @@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory; import reactor.core.Exceptions; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; public final class VaultServiceTokenSupplier { @@ -107,6 +108,7 @@ public VaultServiceTokenSupplier serviceTokenNameBuilder( public Mono getToken(Map tags) { return Mono.fromRunnable(this::validate) .then(Mono.defer(() -> vaultTokenSupplier)) + .subscribeOn(Schedulers.boundedElastic()) .flatMap( vaultToken -> { final String uri = buildServiceTokenUri(tags);