Class EnvoyRateLimiter
- java.lang.Object
-
- org.apache.beam.sdk.io.components.ratelimiter.EnvoyRateLimiter
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.AutoCloseable,RateLimiter
public class EnvoyRateLimiter extends java.lang.Object implements RateLimiter
A lightweight handle for an Envoy-based rate limiter.Delegates work to the
EnvoyRateLimiterFactoryusing the baked-inEnvoyRateLimiterContext.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EnvoyRateLimiter(EnvoyRateLimiterFactory factory, EnvoyRateLimiterContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallow(int permits)Blocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.voidclose()
-
-
-
Constructor Detail
-
EnvoyRateLimiter
public EnvoyRateLimiter(EnvoyRateLimiterFactory factory, EnvoyRateLimiterContext context)
-
-
Method Detail
-
allow
public boolean allow(int permits) throws java.io.IOException, java.lang.InterruptedExceptionDescription copied from interface:RateLimiterBlocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.- Specified by:
allowin interfaceRateLimiter- Parameters:
permits- Number of permits to acquire.- Returns:
- true if the request was allowed, false if it was rejected (and retries exceeded).
- Throws:
java.io.IOException- if there is an error communicating with the rate limiter service.java.lang.InterruptedException- if the thread is interrupted while waiting.
-
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
-