Class RateLimiter.BucketBuilder

  • Enclosing interface:
    RateLimiter

    public static class RateLimiter.BucketBuilder
    extends java.lang.Object
    Used for building instances of RateLimiter that respect a bucket system.
    See Also:
    RateLimiter.bucketBuilder()
    • Method Detail

      • tasksPerPeriod

        @Nonnull
        public RateLimiter.BucketBuilder tasksPerPeriod​(@Nonnegative @Nullable
                                                        java.lang.Integer tasksPerPeriod)
        Sets the maximum amount of tasks that will be executed in a given period.
        Parameters:
        tasksPerPeriod - the maximum amount of tasks per period or null
        Returns:
        itself for chaining
        Throws:
        java.lang.IllegalArgumentException - if tasksPerPeriod is negative
      • period

        @Nonnull
        public RateLimiter.BucketBuilder period​(@Nonnegative @Nullable
                                                java.lang.Long period)
        Sets the period according to which tasks will be scheduled.
        Parameters:
        period - the period according to which tasks will be executed or null
        Returns:
        itself for chaining
        Throws:
        java.lang.IllegalArgumentException - if period is negative
      • build

        @Nonnull
        public RateLimiter build()
        Builds the RateLimiter instance.
        Returns:
        the RateLimiter instance