Skip to main content

quota

Rate limiting and usage quota enforcement per tenant. Tracks requests, tokens, and cost across time windows (minute, hour, day). Supports Postgres and Dragonfly backends with override rules and cleanup.

Used by cmd/worker, cmd/ui.

Usage

import "cruvero/internal/quota"

Key Types / Interfaces

TypeSourceDescription
QuotaStorestore.goInterface for quota tracking: increment, check, reset, override
MaintenanceStorestore.goInterface for quota data cleanup
QuotaStatetypes.goCurrent quota state for a tenant-window pair
QuotaDecisiontypes.goDecision: allowed, reason, retry-after, remaining
QuotaRemainingtypes.goRemaining quota metrics (requests, tokens, cost)
Limitstypes.goQuota limits per time window and cost cap
OverrideRuletypes.goTemporary quota override with expiration
QuotaExceededErrortypes.goCustom error for quota exceeded
TokenBucketbucket.goToken bucket rate limiter
SlidingWindowwindow.goSliding window quota limiter