Skip to content

Commit

Permalink
Merge pull request #98 from scalecube/defer_token_call_to_thread
Browse files Browse the repository at this point in the history
Deferred token retrieval to scheduler
  • Loading branch information
artem-v authored Jun 14, 2023
2 parents f0b0ddb + 529bbfa commit 38973dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -87,6 +88,7 @@ public VaultClientTokenSupplier vaultRole(String vaultRole) {
public Mono<String> 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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -107,6 +108,7 @@ public VaultServiceTokenSupplier serviceTokenNameBuilder(
public Mono<String> getToken(Map<String, String> tags) {
return Mono.fromRunnable(this::validate)
.then(Mono.defer(() -> vaultTokenSupplier))
.subscribeOn(Schedulers.boundedElastic())
.flatMap(
vaultToken -> {
final String uri = buildServiceTokenUri(tags);
Expand Down

0 comments on commit 38973dd

Please sign in to comment.