Versions in this module Expand all Collapse all v1 v1.4.1 Jul 26, 2026 v1.1.0 Jul 21, 2026 Changes in this version + func WriteLimitError(w http.ResponseWriter, err error) bool + type Counter interface + CountAgentsByUser func(ctx context.Context, userID string) (int, error) + CountDomainsByUser func(ctx context.Context, userID string) (int, error) + GetStorageBytes func(ctx context.Context, userID string) (int64, error) + MessagesThisMonth func(ctx context.Context, userID string) (int, error) + type DBEnforcer struct + func NewEnforcer(store *Store, counter Counter, defaults Defaults, cacheTTL time.Duration) *DBEnforcer + func (e *DBEnforcer) CheckAgentCreate(ctx context.Context, userID string) error + func (e *DBEnforcer) CheckDomainCreate(ctx context.Context, userID string) error + func (e *DBEnforcer) CheckMessageSend(ctx context.Context, userID string) error + func (e *DBEnforcer) Get(ctx context.Context, userID string) (Limits, error) + func (e *DBEnforcer) Invalidate(userID string) + type Defaults struct + MaxAgents int + MaxDomains int + MaxMessagesMonth int + MaxStorageBytes int64 + PlanCode string + type Enforcer interface + CheckAgentCreate func(ctx context.Context, userID string) error + CheckDomainCreate func(ctx context.Context, userID string) error + CheckMessageSend func(ctx context.Context, userID string) error + Get func(ctx context.Context, userID string) (Limits, error) + Invalidate func(userID string) + type LimitErrorBody struct + Current int + Error string + Limit int + PlanCode string + Resource string + UpgradeURL string + type LimitExceededError struct + Current int + Limit int + Limits Limits + Resource string + func IsLimitExceeded(err error) (*LimitExceededError, bool) + func (e *LimitExceededError) Error() string + type Limits struct + MaxAgents int + MaxDomains int + MaxMessagesMonth int + MaxStorageBytes int64 + PlanCode string + UpgradeURL string + type Store struct + func NewStore(pool *pgxpool.Pool) *Store + func (s *Store) Get(ctx context.Context, userID string) (Limits, bool, error) + func (s *Store) Upsert(ctx context.Context, userID string, l Limits) error