diff --git a/pom.xml b/pom.xml index 1d6a4c2..ca3721c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.rbkmoney adapter-bank-spring-boot-starter - 0.0.10 + 0.0.11 jar @@ -17,6 +17,7 @@ 1.363-3074af1 0.6.7 2.1.10 + 0.0.14 @@ -102,7 +103,7 @@ com.rbkmoney adapter-common-lib - 0.0.13 + ${adapter-common-lib.version} diff --git a/src/main/java/com/rbkmoney/adapter/bank/spring/boot/starter/backoff/BackOffUtils.java b/src/main/java/com/rbkmoney/adapter/bank/spring/boot/starter/backoff/BackOffUtils.java deleted file mode 100644 index 450ef28..0000000 --- a/src/main/java/com/rbkmoney/adapter/bank/spring/boot/starter/backoff/BackOffUtils.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.rbkmoney.adapter.bank.spring.boot.starter.backoff; - -import com.rbkmoney.adapter.common.model.AdapterContext; -import com.rbkmoney.adapter.common.state.backoff.BackOffExecution; -import com.rbkmoney.adapter.common.state.backoff.ExponentialBackOff; -import com.rbkmoney.adapter.common.state.backoff.TimeOptionsExtractors; - -import java.time.Instant; -import java.util.Map; - -import static com.rbkmoney.adapter.common.state.backoff.ExponentialBackOff.*; - -public class BackOffUtils { - - public static BackOffExecution prepareBackOffExecution( - AdapterContext adapterContext, - Map options) { - return exponentialBackOff(adapterContext, options) - .start(); - } - - public static int prepareNextPollingInterval( - AdapterContext adapterContext, - Map options) { - return exponentialBackOff(adapterContext, options) - .start() - .nextBackOff() - .intValue(); - } - - private static ExponentialBackOff exponentialBackOff( - AdapterContext adapterContext, - Map options) { - final Long currentLocalTime = Instant.now().toEpochMilli(); - - Long startTime = adapterContext.getStartDateTimePolling() != null - ? adapterContext.getStartDateTimePolling().toEpochMilli() - : currentLocalTime; - Integer exponential = TimeOptionsExtractors.extractExponent(options, DEFAULT_EXPONENTIAL); - Integer defaultInitialExponential = TimeOptionsExtractors.extractDefaultInitialExponential(options, DEFAULT_INITIAL_EXPONENTIAL); - Integer maxTimeBackOff = TimeOptionsExtractors.extractMaxTimeBackOff(options, DEFAULT_MAX_TIME_BACK_OFF); - - return new ExponentialBackOff( - startTime, - currentLocalTime, - exponential, - defaultInitialExponential, - maxTimeBackOff); - } -} \ No newline at end of file