Versions in this module Expand all Collapse all v1 v1.1.0 Apr 1, 2026 Changes in this version + var ErrInvalidKey = errors.New("ratelimit: invalid key") + var ErrQuotaNotFound = errors.New("ratelimit: quota not found") + var ErrRateLimitExceeded = errors.New("ratelimit: quota exceeded") + type QuotaConfig struct + TenantRequestsPerMinute int64 + TenantTokensPerMinute int64 + UserRequestsPerMinute int64 + UserTokensPerMinute int64 + type QuotaStore interface + GetQuota func(ctx context.Context, tenantID string) (*QuotaConfig, error) + SetQuota func(ctx context.Context, tenantID string, config *QuotaConfig) error + type RateLimitKey struct + SkillID string + TenantID string + UserID string + type RateLimitResult struct + Allowed bool + Remaining int64 + ResetAt time.Time + RetryAfter time.Duration + type RateLimiter interface + Allow func(ctx context.Context, key RateLimitKey) (*RateLimitResult, error) + Consume func(ctx context.Context, key RateLimitKey, tokens int64) error + Remaining func(ctx context.Context, key RateLimitKey) (int64, error) + Reset func(ctx context.Context, key RateLimitKey) error