Class EnvoyRateLimiterFactory
java.lang.Object
org.apache.beam.sdk.io.components.ratelimiter.EnvoyRateLimiterFactory
- All Implemented Interfaces:
Serializable,AutoCloseable,RateLimiterFactory
A
RateLimiterFactory for Envoy Rate Limit Service.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallow(RateLimiterContext context, 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()getLimiter(RateLimiterContext context) Creates a lightweight ratelimiter handle bound to a specific context.
-
Constructor Details
-
EnvoyRateLimiterFactory
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getLimiter
Description copied from interface:RateLimiterFactoryCreates a lightweight ratelimiter handle bound to a specific context.Use this when passing ratelimiter to IO components, which doesn't need to know about the configuration or the underlying ratelimiter service details. This is also useful in DoFns when you want to use the ratelimiter in a static way based on the compile time context.
- Specified by:
getLimiterin interfaceRateLimiterFactory- Parameters:
context- The context for the ratelimit.- Returns:
- A
RateLimiterhandle.
-
allow
public boolean allow(RateLimiterContext context, int permits) throws IOException, InterruptedException Description copied from interface:RateLimiterFactoryBlocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.Use this for when the ratelimit namespace or descriptors are not known at compile time. allows you to use the ratelimiter in a dynamic way based on the runtime data.
- Specified by:
allowin interfaceRateLimiterFactory- Parameters:
context- The context for the ratelimit.permits- Number of permits to acquire.- Returns:
- true if the request is allowed, false if rejected.
- Throws:
IOException- if there is an error communicating with the ratelimiter service.InterruptedException- if the thread is interrupted while waiting.
-