Documentation
¶
Overview ¶
Package spendlimit names the monetary limit subjects, periods and refusal reasons, and computes the UTC calendar windows they reset on. It is a leaf package so the throttle, the router and the HTTP layer agree on one contract.
Index ¶
Constants ¶
const ( SubjectKey = "key" // api key name SubjectUser = "user" // router.UserID: attributes["user_id"] or svc:<key_name> SubjectTeam = "team" // team id )
Subject types a limit can apply to.
const ( PeriodDay = "day" PeriodMonth = "month" )
Periods are UTC calendar windows.
ReasonUnavailable is reported when the counters cannot be read and SPEND_LIMITS_FAIL_MODE=closed.
const Wildcard = "*"
Wildcard as a subject id is the default limit for every subject of a type.
Variables ¶
var Enforced = []struct{ Subject, Period string }{ {SubjectKey, PeriodDay}, {SubjectKey, PeriodMonth}, {SubjectUser, PeriodDay}, {SubjectUser, PeriodMonth}, {SubjectTeam, PeriodMonth}, }
Enforced lists the (subject, period) pairs checked on every call, in the order a refusal names them.
Functions ¶
func RetryAfter ¶
RetryAfter is the time until the period behind a spend refusal resets, rounded up to whole seconds. ok is false for any other kind.
func ValidSubject ¶
ValidSubject reports a subject type that is enforced.
Types ¶
This section is empty.