HedgingTokenBucket

HedgingTokenBucket

Fixed-point token bucket rate limiter for publish hedging.

Starts empty (0 tokens), refills by refillRatio on each successful publish batch (capped at maxTokens), and requires 1.0 token per hedged attempt.

Constructor

new HedgingTokenBucket()

Methods

getTokenBalance()

Returns the current logical token balance (for testing/inspection).

refillTokenBucket()

Refills the token bucket after a successful publish batch.

tryAcquireHedgeToken()

Attempts to consume 1.0 token for a hedged request. Returns true if a token was available and consumed, false otherwise.

(static) resolveInitialRpcTimeout()

Resolves the effective initial RPC timeout Duration from CallOptions.

(static) resolveTotalTimeout()

Resolves the effective total timeout Duration from CallOptions.

(static) validateAndResolveHedgingOptions()

Validates user-supplied HedgingOptions, applies defaults, and verifies compatibility with messageOrdering and RPC/total timeouts.