Skip to content

Commit 156f690

Browse files
committed
feat: slowIo support
1 parent c1df4e3 commit 156f690

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

backend/src/main/java/ch/xxx/trader/usecase/services/CoinbaseService.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ private record GetSetMethodFunctions(Function<QuoteCb, BigDecimal> getter, BiCon
8686
private final Scheduler mongoScheduler = Schedulers.newBoundedElastic(6, 10, "mongoImport", 10);
8787
@Value("${single.instance.deployment:false}")
8888
private boolean singleInstanceDeployment;
89+
@Value("${single.instance.slow-io:false}")
90+
private boolean slowIo;
8991

9092
public CoinbaseService(MyMongoRepository myMongoRepository, ServiceUtils serviceUtils) {
9193
this.myMongoRepository = myMongoRepository;
@@ -204,13 +206,13 @@ private void processTimeFrame(MyTimeFrame timeFrame1, boolean isDay) {
204206
// Coinbase
205207
final var logFailed = String.format("Coinbase prepare %s data failed", isDay ? "day" : "hour");
206208
Mono<Collection<QuoteCb>> collectCb = this.myMongoRepository.find(query, QuoteCb.class)
207-
.timeout(Duration.ofSeconds(30L)).doOnError(ex -> LOG.warn(logFailed, ex))
209+
.timeout(this.slowIo ? Duration.ofSeconds(30L) : Duration.ofSeconds(10L)).doOnError(ex -> LOG.warn(logFailed, ex))
208210
.onErrorResume(ex -> Mono.empty()).subscribeOn(this.mongoScheduler).collectList()
209211
.map(quotes -> this.createCbQuoteTimeFrame(timeFrame1, isDay, quotes));
210212
collectCb.filter(Predicate.not(Collection::isEmpty))
211213
.map(myColl -> this.countRelevantProperties(nonZeroProperties, myColl))
212214
.flatMap(myColl -> this.myMongoRepository.insertAll(Mono.just(myColl), isDay ? CB_DAY_COL : CB_HOUR_COL)
213-
.timeout(Duration.ofSeconds(30L)).doOnError(ex -> LOG.warn(logFailed, ex))
215+
.timeout(this.slowIo ? Duration.ofSeconds(30L) : Duration.ofSeconds(10L)).doOnError(ex -> LOG.warn(logFailed, ex))
214216
.onErrorResume(ex -> Mono.empty()).subscribeOn(this.mongoScheduler).collectList())
215217
.subscribeOn(this.mongoScheduler).block();
216218
LOG.info(String.format("Prepared Coinbase %s Data for: ", isDay ? "Day" : "Hour")

backend/src/main/resources/application.properties

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ server.compression.min-response-size=2KB
1616
spring.codec.max-in-memory-size=2MB
1717
server.servlet.session.timeout=10s
1818
kubernetes.pod.cpu.constraint=${CPU_CONSTRAINT:false}
19+
single.instance.slow-io=false
1920
single.instance.deployment=false
2021
management.health.livenessstate.enabled=true
2122
management.health.readinessstate.enabled=true

0 commit comments

Comments
 (0)