Limiter config is transport/limiter.Config and is typically applied at transport level.
Supported key kinds (built-in):
user-idtransport-service-methodservice-methodipuser-agentExample:
transport:
http:
limiter:
kind: user-agent
tokens: 10
interval: 1s
max_keys: 4096
[!NOTE]
- Omitting the
limiterblock disables limiting entirely; a nil config is treated as disabled.intervalis parsed as a Go duration string. Invalid values can fail fast.tokensandintervaluse the underlying in-memory store defaults when set to zero:1token per1s. Configure positive values for explicit quotas.max_keyscaps the number of caller-derived keys that receive independent in-memory buckets. A zero value uses the default4096; additional distinct keys share one overflow bucket.- The built-in limiter is an in-memory, per-process safeguard. Use it as a last resort and prefer an external edge, gateway, ingress, load balancer, or service-mesh limiter for production abuse protection.
- The
user-idkey uses the verified principal stored in metadata. For JWT/PASETO tokens this is the subject claim. Prefer it when authenticated identity is available.- The
transport-service-methodkey prefixes the service-method value with the transport name, such ashttp:GET /users/{id}orgrpc:/users.v1.Users/Get, so HTTP and gRPC operations use separate buckets.- The
service-methodkey uses HTTP route/path metadata or the gRPC full method name. Prefertransport-service-methodunless cross-transport operations intentionally share quota.- Server-side HTTP and gRPC limiters run after metadata extraction and token verification, so missing, malformed, or invalid authorization is rejected before it reaches the limiter. This is intentional; enforce quotas for those attempts with an external edge, gateway, ingress, load balancer, or service-mesh limiter.
- Server-side HTTP limiters set
RateLimitandRateLimit-Policyheaders; denied HTTP requests also setRetry-Afterwhen reset timing is available. Server-side gRPC limiters setratelimitandratelimit-policyresponse metadata; denied gRPC requests also attach agoogle.rpc.RetryInfodetail when reset timing is available.- gRPC stream limiters consume one token when the stream opens and one token for each
RecvMsgandSendMsgoperation. Unary HTTP and gRPC requests consume one token per request/RPC.