Package io.grpc.rls
Interface Throttler
-
- All Known Implementing Classes:
AdaptiveThrottler
,CachingRlsLbClient.HappyThrottler
@ThreadSafe interface Throttler
A strategy for deciding when to throttle requests at the client.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
registerBackendResponse(boolean throttled)
Registers a response received from the backend for a request allowed by shouldThrottle.boolean
shouldThrottle()
Checks if a given request should be throttled by the client.
-
-
-
Method Detail
-
shouldThrottle
boolean shouldThrottle()
Checks if a given request should be throttled by the client. This should be called for every request before allowing it to hit the network. If the returned value is true, the request should be aborted immediately (as if it had been throttled by the server).This updates internal state and should be called exactly once for each request.
-
registerBackendResponse
void registerBackendResponse(boolean throttled)
Registers a response received from the backend for a request allowed by shouldThrottle. This should be called for every response received from the backend (i.e., once for each request for which ShouldThrottle returned false). This updates the internal statistics used by shouldThrottle.- Parameters:
throttled
- specifies whether the request was throttled by the backend.
-
-