Interface ThroughputLimitConfig

All Superinterfaces:
Prototype.Api, Prototype.Factory<ThroughputLimit>
All Known Implementing Classes:
ThroughputLimitConfig.BuilderBase.ThroughputLimitConfigImpl

public interface ThroughputLimitConfig extends Prototype.Api
Configuration of ThroughputLimit.
See Also:
  • Method Details

    • builder

      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      Create a new fluent API builder from an existing instance.
      Parameters:
      instance - an existing instance used as a base for the builder
      Returns:
      a builder based on an instance
    • create

      static ThroughputLimitConfig create(Config config)
      Create a new instance from configuration.
      Parameters:
      config - used to configure the new instance
      Returns:
      a new instance configured from configuration
    • create

      @Deprecated static ThroughputLimitConfig create(Config config)
      Create a new instance from configuration.
      Parameters:
      config - used to configure the new instance
      Returns:
      a new instance configured from configuration
    • create

      static ThroughputLimitConfig create()
      Create a new instance with default values.
      Returns:
      a new instance
    • rateLimitingAlgorithm

      RateLimitingAlgorithmType rateLimitingAlgorithm()
      The rate limiting algorithm to apply. Rate limiting algorithm is by default RateLimitingAlgorithmType.TOKEN_BUCKET.
      Returns:
      the rate limiting algorithm to be applied
    • amount

      int amount()
      Number of operations to allow during the relevant time window. Defaults to 0. When set to 0, we switch to unlimited.
      Returns:
      number of permits
    • duration

      Duration duration()
      Duration of the time window over which operations will be counted. Defaults to "PT1S"
      Returns:
      duration of the time window
    • fair

      boolean fair()
      Whether the Semaphore should be Semaphore.isFair(). Defaults to false.
      Returns:
      whether this should be a fair semaphore
    • queueLength

      int queueLength()
      How many requests can be enqueued waiting for a permit. Note that this may not be an exact behavior due to concurrent invocations. We use Semaphore.getQueueLength() in the ThroughputLimit implementation. Default value is 0. If set to {code 0}, there is no queueing.
      Returns:
      number of requests to enqueue
    • queueTimeout

      Duration queueTimeout()
      How long to wait for a permit when enqueued. Defaults to "PT1S"
      Returns:
      duration of the timeout
    • name

      String name()
      Name of this instance.
      Returns:
      name of the instance
    • semaphore

      Optional<Semaphore> semaphore()
      Explicitly configured semaphore. Note that if this is set, all other configuration is ignored.
      Returns:
      semaphore instance
    • clock

      A clock that supplies nanosecond time.
      Returns:
      supplier of current nanoseconds, defaults to System.nanoTime()
    • enableMetrics

      boolean enableMetrics()
      Whether to collect metrics for the throughput limit implementation.
      Returns:
      metrics flag