Class CacheConfig.Builder

java.lang.Object
org.kiwiproject.consul.config.CacheConfig.Builder
Enclosing class:
CacheConfig

public static class CacheConfig.Builder extends Object
  • Method Details

    • withWatchDuration

      public CacheConfig.Builder withWatchDuration(Duration delay)
      Sets the watch duration used in caches.
      Parameters:
      delay - the watch duration to use
      Returns:
      the Builder instance
      Throws:
      IllegalArgumentException - if delay is negative.
    • withBackOffDelay

      public CacheConfig.Builder withBackOffDelay(Duration delay)
      Sets the back-off delay used in caches.
      Parameters:
      delay - the back-off delay to use
      Returns:
      the Builder instance
      Throws:
      IllegalArgumentException - if delay is negative.
    • withBackOffDelay

      public CacheConfig.Builder withBackOffDelay(Duration minDelay, Duration maxDelay)
      Sets a random delay between the minDelay and maxDelay (inclusive) to occur between retries.
      Parameters:
      minDelay - the minimum delay between retries
      maxDelay - the maximum delay between retries
      Returns:
      the Builder instance
      Throws:
      IllegalArgumentException - if minDelay or maxDelay is negative, or if minDelay is greater than to maxDelay.
    • withMinDelayBetweenRequests

      public CacheConfig.Builder withMinDelayBetweenRequests(Duration delay)
      Sets the minimum time between two requests for caches.
      Parameters:
      delay - the minimum time between two requests to use
      Returns:
      the Builder instance
    • withMinDelayOnEmptyResult

      public CacheConfig.Builder withMinDelayOnEmptyResult(Duration delay)
      Sets the minimum time between two requests for caches when an empty result is returned.
      Parameters:
      delay - the minimum time between two requests to use when an empty result is returned
      Returns:
      the Builder instance
    • withTimeoutAutoAdjustmentEnabled

      public CacheConfig.Builder withTimeoutAutoAdjustmentEnabled(boolean enabled)
      Enable/Disable the automatic adjustment of read timeout
      Parameters:
      enabled - use true to enable automatic adjustment of read timeout, false to disable
      Returns:
      the Builder instance
    • withTimeoutAutoAdjustmentMargin

      public CacheConfig.Builder withTimeoutAutoAdjustmentMargin(Duration margin)
      Sets the margin of the read timeout for caches.

      The margin represents the additional amount of time given to the read timeout, in addition to the wait duration.

      Parameters:
      margin - the margin of the read timeout to use
      Returns:
      the Builder instance
    • withRefreshErrorLoggedAsWarning

      public CacheConfig.Builder withRefreshErrorLoggedAsWarning()
      Log refresh errors as warning
      Returns:
      the Builder instance
    • withRefreshErrorLoggedAsError

      public CacheConfig.Builder withRefreshErrorLoggedAsError()
      Log refresh errors as error
      Returns:
      the Builder instance
    • withRefreshErrorLoggedAs

      public CacheConfig.Builder withRefreshErrorLoggedAs(CacheConfig.RefreshErrorLogConsumer fn)
      Log refresh errors using custom function
      Parameters:
      fn - the custom function to use when an error occurs
      Returns:
      the Builder instance
    • build

      public CacheConfig build()