Add latency to simulate long database queries.

This commit is contained in:
Florian THIERRY
2025-09-18 17:51:55 +02:00
parent 9dce18d00f
commit 2fe14de357
5 changed files with 27 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import java.time.Duration;
import java.util.UUID;
@Component
@@ -31,6 +32,7 @@ public class CatalogJpaAdapter implements CatalogPort {
public Flux<Catalog> getAll() {
return Mono.fromCallable(catalogJpaRepository::findAll)
.subscribeOn(Schedulers.boundedElastic())
.delayElement(Duration.ofSeconds(1))
.flatMapMany(Flux::fromIterable)
.map(CatalogJpaEntity::toDomain);
}

View File

@@ -9,6 +9,9 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import java.time.Duration;
@Component
public class ItemJpaAdapter implements ItemPort {
private final ItemJpaRepository itemJpaRepository;
@@ -21,6 +24,7 @@ public class ItemJpaAdapter implements ItemPort {
public Flux<Item> getAll() {
return Mono.fromCallable(itemJpaRepository::findAll)
.subscribeOn(Schedulers.boundedElastic())
.delayElement(Duration.ofSeconds(1))
.flatMapMany(Flux::fromIterable)
.map(ItemJpaEntity::toDomain);
}