Class RateLimiterOperator<T>

java.lang.Object
io.github.resilience4j.reactor.ratelimiter.operator.RateLimiterOperator<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
Function<org.reactivestreams.Publisher<T>,org.reactivestreams.Publisher<T>>, UnaryOperator<org.reactivestreams.Publisher<T>>

public class RateLimiterOperator<T> extends Object implements UnaryOperator<org.reactivestreams.Publisher<T>>
A RateLimiter operator which checks if a downstream subscriber/observer can acquire a permission to subscribe to an upstream Publisher. Otherwise emits a RequestNotPermitted if the rate limit is exceeded.
  • Method Details

    • of

      public static <T> RateLimiterOperator<T> of(io.github.resilience4j.ratelimiter.RateLimiter rateLimiter)
      Creates a RateLimiterOperator.
      Type Parameters:
      T - the value type of the upstream and downstream
      Parameters:
      rateLimiter - the Rate limiter
      Returns:
      a RateLimiterOperator
    • of

      public static <T> RateLimiterOperator<T> of(io.github.resilience4j.ratelimiter.RateLimiter rateLimiter, int permits)
      Creates a RateLimiterOperator with custom call weight.
      Type Parameters:
      T - the value type of the upstream and downstream
      Parameters:
      rateLimiter - the Rate limiter
      permits - number of permits - use for systems where 1 call != 1 permit
      Returns:
      a RateLimiterOperator
    • apply

      public org.reactivestreams.Publisher<T> apply(org.reactivestreams.Publisher<T> publisher)
      Specified by:
      apply in interface Function<org.reactivestreams.Publisher<T>,org.reactivestreams.Publisher<T>>