Package org.knowm.xchange.service
Class BaseResilientExchangeService<E extends Exchange>
java.lang.Object
org.knowm.xchange.service.BaseExchangeService<E>
org.knowm.xchange.service.BaseResilientExchangeService<E>
- Direct Known Subclasses:
BinanceBaseService
,BitfinexBaseService
,BittrexBaseService
,BlockchainBaseService
,CoinbaseProBaseService
,KucoinBaseService
,LivecoinBaseService
,OkexBaseService
public abstract class BaseResilientExchangeService<E extends Exchange>
extends BaseExchangeService<E>
Abstract class for an "exchange service" which supports resiliency features like retries, rate
limiting etc.
-
Field Summary
FieldsFields inherited from class org.knowm.xchange.service.BaseExchangeService
exchange
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseResilientExchangeService
(E exchange, ResilienceRegistries resilienceRegistries) -
Method Summary
Modifier and TypeMethodDescriptiondecorateApiCall
(ResilienceUtils.CallableApi<R> callable) Use this method to decorate API calls with resiliency features like retries, rate limiters, etc.protected io.github.resilience4j.ratelimiter.RateLimiter
rateLimiter
(String name) Returns a managedRateLimiter
or creates a new one with the default RateLimiter configuration.protected io.github.resilience4j.ratelimiter.RateLimiter
rateLimiter
(String name, String configName) Returns a managedRateLimiter
or creates a new one.protected io.github.resilience4j.retry.Retry
Returns a managedRetry
or creates a new one with the default Retry configuration fromResilienceRegistries.DEFAULT_RETRY_CONFIG
.protected io.github.resilience4j.retry.Retry
Returns a managedRetry
or creates a new one.Methods inherited from class org.knowm.xchange.service.BaseExchangeService
verifyOrder, verifyOrder, verifyOrder
-
Field Details
-
resilienceRegistries
-
-
Constructor Details
-
BaseResilientExchangeService
-
-
Method Details
-
decorateApiCall
public <R> ResilienceUtils.DecorateCallableApi<R> decorateApiCall(ResilienceUtils.CallableApi<R> callable) Use this method to decorate API calls with resiliency features like retries, rate limiters, etc.- Type Parameters:
R
- type returned by the API call- Parameters:
callable
- call to exchange API- Returns:
- builder of a decorated API call
-
retry
Returns a managedRetry
or creates a new one with the default Retry configuration fromResilienceRegistries.DEFAULT_RETRY_CONFIG
.- Parameters:
name
- the name of the Retry- Returns:
- The
Retry
- See Also:
-
RetryRegistry.retry(String)
-
retry
Returns a managedRetry
or creates a new one. The configuration must have been added upfront inresilienceRegistries
viaResilienceRegistries.retries()
and theRegistry.addConfiguration(String, Object)
method. You can also used a predefined retry likeResilienceRegistries.NON_IDEMPOTENT_CALLS_RETRY_CONFIG_NAME
.- Parameters:
name
- the name of the RetryconfigName
- the name of the shared configuration- Returns:
- The
Retry
- See Also:
-
RetryRegistry.retry(String, String)
-
rateLimiter
Returns a managedRateLimiter
or creates a new one with the default RateLimiter configuration. One main shared rate limiter should be defined for each exchange module viaResilienceRegistries.rateLimiters()
()} and theRegistry.addConfiguration(String, Object)
method.- Parameters:
name
- the name of the RateLimiter- Returns:
- The
RateLimiter
- See Also:
-
RateLimiterRegistry.rateLimiter(String)
-
rateLimiter
protected io.github.resilience4j.ratelimiter.RateLimiter rateLimiter(String name, String configName) Returns a managedRateLimiter
or creates a new one. The configuration must have been added upfrontresilienceRegistries
viaResilienceRegistries.rateLimiters()
()} and theRegistry.addConfiguration(String, Object)
method.- Parameters:
name
- the name of the RateLimiterconfigName
- the name of the shared configuration- Returns:
- The
RateLimiter
- See Also:
-
RateLimiterRegistry.rateLimiter(String, String)
-