Class FixedLimitConfig.BuilderBase<BUILDER extends FixedLimitConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends FixedLimitConfig>

java.lang.Object
io.helidon.common.concurrency.limits.FixedLimitConfig.BuilderBase<BUILDER, PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER, PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Direct Known Subclasses:
FixedLimitConfig.Builder
Enclosing interface:
FixedLimitConfig

public abstract static class FixedLimitConfig.BuilderBase<BUILDER extends FixedLimitConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends FixedLimitConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Fluent API builder base for FixedLimitConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(FixedLimitConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(FixedLimitConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends FixedLimitConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends FixedLimitConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • permits

      public BUILDER permits(int permits)
      Number of permits to allow. Defaults to 0. When set to 0, we switch to unlimited.
      Parameters:
      permits - number of permits
      Returns:
      updated builder instance
      See Also:
    • fair

      public BUILDER fair(boolean fair)
      Whether the Semaphore should be Semaphore.isFair(). Defaults to false.
      Parameters:
      fair - whether this should be a fair semaphore
      Returns:
      updated builder instance
      See Also:
    • queueLength

      public BUILDER 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 FixedLimit implementation. Default value is 0. If set to 0, there is no queueing.
      Parameters:
      queueLength - number of requests to enqueue
      Returns:
      updated builder instance
      See Also:
    • queueTimeout

      public BUILDER queueTimeout(Duration queueTimeout)
      How long to wait for a permit when enqueued. Defaults to "PT1S"
      Parameters:
      queueTimeout - duration of the timeout
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name of this instance.
      Parameters:
      name - name of the instance
      Returns:
      updated builder instance
      See Also:
    • clearSemaphore

      public BUILDER clearSemaphore()
      Clear existing value of semaphore.
      Returns:
      updated builder instance
      See Also:
    • semaphore

      public BUILDER semaphore(Semaphore semaphore)
      Explicitly configured semaphore. Note that if this is set, all other configuration is ignored.
      Parameters:
      semaphore - semaphore instance
      Returns:
      updated builder instance
      See Also:
    • clearClock

      public BUILDER clearClock()
      Clear existing value of clock.
      Returns:
      updated builder instance
      See Also:
    • clock

      public BUILDER clock(Supplier<Long> clock)
      A clock that supplies nanosecond time.
      Parameters:
      clock - supplier of current nanoseconds, defaults to System.nanoTime()
      Returns:
      updated builder instance
      See Also:
    • enableMetrics

      public BUILDER enableMetrics(boolean enableMetrics)
      Whether to collect metrics for the fixed limit implementation.
      Parameters:
      enableMetrics - metrics flag
      Returns:
      updated builder instance
      See Also:
    • permits

      public int permits()
      Number of permits to allow. Defaults to 0. When set to 0, we switch to unlimited.
      Returns:
      number of permits
    • fair

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

      public 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 FixedLimit implementation. Default value is 0. If set to 0, there is no queueing.
      Returns:
      number of requests to enqueue
    • queueTimeout

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

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

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

      public Optional<Supplier<Long>> clock()
      A clock that supplies nanosecond time.
      Returns:
      supplier of current nanoseconds, defaults to System.nanoTime()
    • enableMetrics

      public boolean enableMetrics()
      Whether to collect metrics for the fixed limit implementation.
      Returns:
      metrics flag
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
    • config

      protected Optional<Config> config()
      Configuration used to configure this instance.
      Returns:
      config instance