Documentation
¶
Overview ¶
Package limits exposes the live state of account concurrency / usage limits (see .design/routing-limits.md) so the UI can show who is busy right now.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Policies *db.LimitPolicyStore
Directory Directory
// OnPolicyChanged runs after a policy is saved (warm start of its window).
OnPolicyChanged func(ai.LimitPolicy)
}
Deps are the optional collaborators of the person / team / model scopes. A nil Policies store switches those scopes (and their API) off.
type Directory ¶
type Directory interface {
// TeamName returns the team's name ("" when the team does not exist).
TeamName(teamID string) string
// KeysOfTeam lists the sharing keys bound to a team.
KeysOfTeam(teamID string) []KeyInfo
// KeyByUserID finds the sharing key behind a user_id.
KeyByUserID(userID string) (KeyInfo, bool)
}
Directory resolves the people and teams policies refer to.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the limits status and policy APIs.
func NewHandler ¶
NewHandler creates the handler. guard may be nil (limits off: empty status).
func (*Handler) DeletePolicy ¶
DeletePolicy DELETE /limit-policies/:kind/:ref.
func (*Handler) ListPolicies ¶
ListPolicies GET /limit-policies.
func (*Handler) RegisterRoutes ¶
RegisterRoutes mounts GET /limits/status.
func (*Handler) UpsertPolicy ¶
UpsertPolicy PUT /limit-policies/:kind/:ref.
type LimitPoliciesResponse ¶
type LimitPoliciesResponse struct {
Success bool `json:"success" example:"true"`
Data []ai.LimitPolicy `json:"data"`
}
LimitPoliciesResponse is the response of GET /limit-policies.
type LimitPolicyQuery ¶
type LimitPolicyQuery struct {
Kind string `form:"kind" description:"user | team | team_member | model"`
Ref string `form:"ref" description:"user_id, team id or model name"`
}
LimitPolicyQuery filters GET /limit-policies.
type LimitPolicyResponse ¶
type LimitPolicyResponse struct {
Success bool `json:"success" example:"true"`
Exists bool `json:"exists" description:"false after a delete or when the saved policy held no limit"`
Data *ai.LimitPolicy `json:"data,omitempty"`
}
LimitPolicyResponse is the response of PUT/DELETE /limit-policies/{kind}/{ref}.
type LimitPolicyUpsertRequest ¶
type LimitPolicyUpsertRequest struct {
Limits ai.Limits `json:"limits"`
Overflow string `json:"overflow,omitempty" description:"user/team/team_member: queue (default) | reject"`
QueueTimeoutSeconds int `json:"queue_timeout_seconds,omitempty"`
}
LimitPolicyUpsertRequest is the body of PUT /limit-policies/{kind}/{ref}. An empty `limits` object deletes the policy.
type LimitStatusEntry ¶
type LimitStatusEntry struct {
Scope string `json:"scope" example:"account" description:"account | service | model | user | team"`
Key string `json:"key"`
Ref string `json:"ref,omitempty" description:"policy ref for user/team/model scopes (user_id, team id, model name)"`
Label string `json:"label,omitempty" description:"human-readable name (key display name, team name, provider name)"`
TeamID string `json:"team_id,omitempty"`
InheritedFrom string `json:"inherited_from,omitempty" description:"team_member when a per-member template governs this person"`
Overflow string `json:"overflow,omitempty" description:"actor scopes: queue | reject"`
QueueTimeout int `json:"queue_timeout_seconds,omitempty"`
ProviderUUID string `json:"provider_uuid,omitempty"`
ProviderName string `json:"provider_name,omitempty"`
RuleUUID string `json:"rule_uuid,omitempty"`
Scenario string `json:"scenario,omitempty"`
RequestModel string `json:"request_model,omitempty"`
Model string `json:"model,omitempty"`
Limits ai.Limits `json:"limits"`
Inflight int `json:"inflight"`
Requests int64 `json:"requests" description:"requests admitted in the current usage window"`
Tokens int64 `json:"tokens" description:"tokens recorded in the current usage window"`
Pressure float64 `json:"pressure" description:"largest used/limit ratio; 1 = at the hard limit"`
State string `json:"state" example:"ok" description:"ok | hot | blocked"`
}
LimitStatusEntry is the live state of one limit: an account, a rule's service share, a model, a person or a team.
type LimitsStatusResponse ¶
type LimitsStatusResponse struct {
Success bool `json:"success" example:"true"`
Data []LimitStatusEntry `json:"data"`
}
LimitsStatusResponse is the response of GET /limits/status.