Documentation ¶
Index ¶
- Variables
- type Context
- type Item
- type Map
- func (m *Map) Get(tag Tag) (int64, bool)
- func (m *Map) Iter() <-chan Item
- func (m *Map) Merge(l2 *Map)
- func (m *Map) Scopes() (map[Scope]struct{}, error)
- func (m *Map) Services() (map[TargetSrv]struct{}, error)
- func (m *Map) Set(tag Tag, limit int64)
- func (m *Map) Targets() (map[Target]struct{}, error)
- type NewUsageReporter
- type Quota
- type QuotaDTO
- type Scope
- type ScopeParameters
- type Service
- type Tag
- type Target
- type TargetSrv
- type TargetToSrv
- type UpdateQuotaCmd
- type UsageReporterFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBadRequest = errutil.BadRequest("quota.bad-request")
View Source
var ErrDisabled = errutil.Forbidden("quota.disabled", errutil.WithPublicMessage("Quotas not enabled"))
View Source
var ErrFailedToGetScope = errutil.Internal("quota.failed-get-scope")
View Source
var ErrInvalidScope = errutil.BadRequest("quota.invalid-scope")
View Source
var ErrInvalidTagFormat = errutil.Internal("quota.invalid-invalid-tag-format")
View Source
var ErrInvalidTarget = errutil.Internal("quota.invalid-target-table")
View Source
var ErrInvalidTargetSrv = errutil.BadRequest("quota.invalid-target")
View Source
var ErrTargetSrvConflict = errutil.BadRequest("quota.target-srv-conflict")
View Source
var ErrUsageFoundForTarget = errutil.NotFound("quota.missing-target-usage")
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { context.Context TargetToSrv *TargetToSrv }
func FromContext ¶
func FromContext(ctx context.Context, targetToSrv *TargetToSrv) Context
type NewUsageReporter ¶
type NewUsageReporter struct { TargetSrv TargetSrv DefaultLimits *Map Reporter UsageReporterFunc }
type QuotaDTO ¶
type ScopeParameters ¶
type Service ¶
type Service interface { // GetQuotasByScope returns the quota for the specific scope (global, organization, user) // If the scope is organization, the ID is expected to be the organisation ID. // If the scope is user, the id is expected to be the user ID. GetQuotasByScope(ctx context.Context, scope Scope, ID int64) ([]QuotaDTO, error) // Update overrides the quota for a specific scope (global, organization, user). // If the cmd.OrgID is set, then the organization quota are updated. // If the cmd.UseID is set, then the user quota are updated. Update(ctx context.Context, cmd *UpdateQuotaCmd) error // QuotaReached is called by the quota middleware for applying quota enforcement to API handlers QuotaReached(c *contextmodel.ReqContext, targetSrv TargetSrv) (bool, error) // CheckQuotaReached checks if the quota limitations have been reached for a specific service CheckQuotaReached(ctx context.Context, targetSrv TargetSrv, scopeParams *ScopeParameters) (bool, error) // DeleteQuotaForUser deletes custom quota limitations for the user DeleteQuotaForUser(ctx context.Context, userID int64) error // RegisterQuotaReporter registers a service UsageReporterFunc, targets and their default limits RegisterQuotaReporter(e *NewUsageReporter) error }
type TargetToSrv ¶
type TargetToSrv struct {
// contains filtered or unexported fields
}
func NewTargetToSrv ¶
func NewTargetToSrv() *TargetToSrv
func (*TargetToSrv) Set ¶
func (m *TargetToSrv) Set(target Target, srv TargetSrv)
type UpdateQuotaCmd ¶
type UsageReporterFunc ¶
type UsageReporterFunc func(ctx context.Context, scopeParams *ScopeParameters) (*Map, error)
Click to show internal directories.
Click to hide internal directories.