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 Details

  • Constructor Details

    • BaseResilientExchangeService

      protected BaseResilientExchangeService(E exchange, ResilienceRegistries resilienceRegistries)
  • 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

      protected io.github.resilience4j.retry.Retry retry(String name)
      Returns a managed Retry or creates a new one with the default Retry configuration from ResilienceRegistries.DEFAULT_RETRY_CONFIG.
      Parameters:
      name - the name of the Retry
      Returns:
      The Retry
      See Also:
      • RetryRegistry.retry(String)
    • retry

      protected io.github.resilience4j.retry.Retry retry(String name, String configName)
      Returns a managed Retry or creates a new one. The configuration must have been added upfront in resilienceRegistries via ResilienceRegistries.retries() and the Registry.addConfiguration(String, Object) method. You can also used a predefined retry like ResilienceRegistries.NON_IDEMPOTENT_CALLS_RETRY_CONFIG_NAME.
      Parameters:
      name - the name of the Retry
      configName - the name of the shared configuration
      Returns:
      The Retry
      See Also:
      • RetryRegistry.retry(String, String)
    • rateLimiter

      protected io.github.resilience4j.ratelimiter.RateLimiter rateLimiter(String name)
      Returns a managed RateLimiter or creates a new one with the default RateLimiter configuration. One main shared rate limiter should be defined for each exchange module via ResilienceRegistries.rateLimiters() ()} and the Registry.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 managed RateLimiter or creates a new one. The configuration must have been added upfront resilienceRegistries via ResilienceRegistries.rateLimiters() ()} and the Registry.addConfiguration(String, Object) method.
      Parameters:
      name - the name of the RateLimiter
      configName - the name of the shared configuration
      Returns:
      The RateLimiter
      See Also:
      • RateLimiterRegistry.rateLimiter(String, String)