Class BucketGlobalRateLimiter

    • Method Detail

      • create

        public static BucketGlobalRateLimiter create​(int capacity,
                                                     Duration refillPeriod,
                                                     Scheduler delayScheduler)
        Creates a new global rate limiter with the given parameters. Be aware that modifying these parameters can lead your bot hitting 429 TOO MANY REQUESTS errors.
        Parameters:
        capacity - the number of requests that can be performed in the given refillPeriod
        refillPeriod - the Duration before refilling request permits
        delayScheduler - the Scheduler used to inject delays
        Returns:
        a BucketGlobalRateLimiter with the given parameters.
      • getRemaining

        public Mono<Duration> getRemaining()
        Description copied from interface: GlobalRateLimiter
        Returns the Duration remaining until the current global rate limit is completed. Can be negative or zero if there is no currently active global rate limit.
        Specified by:
        getRemaining in interface GlobalRateLimiter
        Returns:
        a positive Duration indicating the remaining time a global rate limit is being applied. Zero or negative if no global rate limit is currently active.
      • withLimiter

        public <T> Flux<T> withLimiter​(Publisher<T> stage)
        Description copied from interface: GlobalRateLimiter
        Provides a scope to perform reactive operations under this global rate limiter. Limiter resources are acquired on subscription and released when the given stage is cancelled, has completed or has been terminated with an error.
        Specified by:
        withLimiter in interface GlobalRateLimiter
        Type Parameters:
        T - the type of the stage supplier
        Parameters:
        stage - a Publisher that will manage this global rate limiter resources
        Returns:
        a Flux where each subscription represents acquiring a rate limiter resource