Interface RRateLimiterReactive
- All Superinterfaces:
RExpirableReactive,RObjectReactive
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> acquire()Acquires a permit from this RateLimiter, blocking until one is available.reactor.core.publisher.Mono<Void> acquire(long permits) Acquires a specifiedpermitsfrom this RateLimiter, blocking until one is available.reactor.core.publisher.Mono<Long> Returns amount of available permits.reactor.core.publisher.Mono<Void> setRate(RateType mode, long rate, long rateInterval, RateIntervalUnit rateIntervalUnit) Deprecated.reactor.core.publisher.Mono<Void> Sets the rate limit and clears the state.reactor.core.publisher.Mono<Void> Sets time to live, the rate limit, and clears the state.reactor.core.publisher.Mono<Boolean> Acquires a permit only if one is available at the time of invocation.reactor.core.publisher.Mono<Boolean> tryAcquire(long permits) Acquires the given number ofpermitsonly if all are available at the time of invocation.reactor.core.publisher.Mono<Boolean> tryAcquire(long permits, long timeout, TimeUnit unit) Deprecated.reactor.core.publisher.Mono<Boolean> tryAcquire(long permits, Duration timeout) Acquires the given number ofpermitsonly if all are available within the given waiting time.reactor.core.publisher.Mono<Boolean> tryAcquire(long timeout, TimeUnit unit) Deprecated.reactor.core.publisher.Mono<Boolean> tryAcquire(Duration timeout) Acquires a permit from this RateLimiter, if one becomes available within the given waiting time.reactor.core.publisher.Mono<Boolean> trySetRate(RateType mode, long rate, long rateInterval, RateIntervalUnit rateIntervalUnit) Deprecated.reactor.core.publisher.Mono<Boolean> trySetRate(RateType mode, long rate, Duration rateInterval) Sets the rate limit only if it hasn't been set before.reactor.core.publisher.Mono<Boolean> trySetRate(RateType mode, long rate, Duration rateInterval, Duration timeToLive) Sets the rate limit only if it hasn't been set before.Methods inherited from interface org.redisson.api.RExpirableReactive
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLiveMethods inherited from interface org.redisson.api.RObjectReactive
addListener, copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Method Details
-
trySetRate
@Deprecated reactor.core.publisher.Mono<Boolean> trySetRate(RateType mode, long rate, long rateInterval, RateIntervalUnit rateIntervalUnit) Deprecated.UsetrySetRate(RateType, long, Duration)instead- Parameters:
mode- rate moderate- raterateInterval- rate time intervalrateIntervalUnit- rate time interval unit- Returns:
trueif rate was set andfalseotherwise
-
trySetRate
Sets the rate limit only if it hasn't been set before.- Parameters:
mode- rate moderate- raterateInterval- rate time interval- Returns:
trueif rate was set andfalseotherwise
-
trySetRate
reactor.core.publisher.Mono<Boolean> trySetRate(RateType mode, long rate, Duration rateInterval, Duration timeToLive) Sets the rate limit only if it hasn't been set before. Time to live is applied only if rate limit has been set successfully.- Parameters:
mode- rate moderate- raterateInterval- rate time intervaltimeToLive- time interval before the object will be deleted- Returns:
trueif rate was set andfalseotherwise
-
setRate
@Deprecated reactor.core.publisher.Mono<Void> setRate(RateType mode, long rate, long rateInterval, RateIntervalUnit rateIntervalUnit) Deprecated.UsesetRate(RateType, long, Duration)instead.- Parameters:
mode- rate moderate- raterateInterval- rate time intervalrateIntervalUnit- rate time interval unit
-
setRate
Sets the rate limit and clears the state. Overrides both limit and state if they haven't been set before.- Parameters:
mode- rate moderate- raterateInterval- rate time interval
-
setRate
reactor.core.publisher.Mono<Void> setRate(RateType mode, long rate, Duration rateInterval, Duration timeToLive) Sets time to live, the rate limit, and clears the state. Overrides both limit and state if they haven't been set before.- Parameters:
mode- rate moderate- raterateInterval- rate time intervaltimeToLive- time interval before the object will be deleted
-
tryAcquire
reactor.core.publisher.Mono<Boolean> tryAcquire()Acquires a permit only if one is available at the time of invocation.Acquires a permit, if one is available and returns immediately, with the value
true, reducing the number of available permits by one.If no permit is available then this method will return immediately with the value
false.- Returns:
trueif a permit was acquired andfalseotherwise
-
tryAcquire
Acquires the given number ofpermitsonly if all are available at the time of invocation.Acquires a permits, if all are available and returns immediately, with the value
true, reducing the number of available permits by given number of permits.If no permits are available then this method will return immediately with the value
false.- Parameters:
permits- the number of permits to acquire- Returns:
trueif a permit was acquired andfalseotherwise
-
acquire
reactor.core.publisher.Mono<Void> acquire()Acquires a permit from this RateLimiter, blocking until one is available.Acquires a permit, if one is available and returns immediately, reducing the number of available permits by one.
- Returns:
- void
-
acquire
Acquires a specifiedpermitsfrom this RateLimiter, blocking until one is available.Acquires the given number of permits, if they are available and returns immediately, reducing the number of available permits by the given amount.
- Parameters:
permits- the number of permits to acquire- Returns:
- void
-
tryAcquire
Deprecated.UsetryAcquire(Duration)instead.- Parameters:
timeout- the maximum time to wait for a permitunit- the time unit of thetimeoutargument- Returns:
trueif a permit was acquired andfalseif the waiting time elapsed before a permit was acquired
-
tryAcquire
Acquires a permit from this RateLimiter, if one becomes available within the given waiting time.Acquires a permit, if one is available and returns immediately, with the value
true, reducing the number of available permits by one.If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until specified waiting time elapses.
If a permit is acquired then the value
trueis returned.If the specified waiting time elapses then the value
falseis returned. If the time is less than or equal to zero, the method will not wait at all.- Parameters:
timeout- the maximum time to wait for a permit- Returns:
trueif a permit was acquired andfalseif the waiting time elapsed before a permit was acquired
-
tryAcquire
@Deprecated reactor.core.publisher.Mono<Boolean> tryAcquire(long permits, long timeout, TimeUnit unit) Deprecated.UsetryAcquire(long, Duration)instead.- Parameters:
permits- amounttimeout- the maximum time to wait for a permitunit- the time unit of thetimeoutargument- Returns:
trueif a permit was acquired andfalseif the waiting time elapsed before a permit was acquired
-
tryAcquire
Acquires the given number ofpermitsonly if all are available within the given waiting time.Acquires the given number of permits, if all are available and returns immediately, with the value
true, reducing the number of available permits by one.If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the specified waiting time elapses.
If a permits is acquired then the value
trueis returned.If the specified waiting time elapses then the value
falseis returned. If the time is less than or equal to zero, the method will not wait at all.- Parameters:
permits- amounttimeout- the maximum time to wait for a permit- Returns:
trueif a permit was acquired andfalseif the waiting time elapsed before a permit was acquired
-
availablePermits
reactor.core.publisher.Mono<Long> availablePermits()Returns amount of available permits.- Returns:
- number of permits
-