quota

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCollectionRequired = fmt.Errorf("quota collection not specified")
	ErrQuotaExceeded      = fmt.Errorf("quota exceeded")
)

Functions

This section is empty.

Types

type Cycle

type Cycle string

Cycle represent the quota refresh cycle

const (
	None   Cycle = ""
	Day    Cycle = "day"
	Month  Cycle = "month"
	Year   Cycle = "year"
	Hour   Cycle = "hour"
	Minute Cycle = "minute"
	Second Cycle = "second"
)

func (Cycle) Current

func (c Cycle) Current() string

Current return the current quota cycle identity in string

type Manager

type Manager interface {
	Acquire(ctx context.Context, account, region, resource string, cycle Cycle, max, n int64) error
	List(ctx context.Context, account, region string, cycle Cycle, resource []string) ([]*Quota, error)
}

func NewManagerFromDB

func NewManagerFromDB(db *sql.DB, table string) (Manager, error)

type Quota

type Quota struct {
	Account string `bson:"account,omitempty" form:"Account" json:"Account,omitempty" query:"Account"`
	// 资源名称
	Resource string `bson:"resource,omitempty" form:"Resource" json:"Resource,omitempty" query:"Resource"`
	// 资源所属 region
	Region string `bson:"region,omitempty" form:"Region" json:"Region,omitempty" query:"Region"`
	// 资源刷新周期
	Cycle string `bson:"cycle,omitempty" form:"Cycle" json:"Cycle,omitempty" query:"Cycle"`
	// 资源总数量
	Capacity int64 `bson:"capacity,omitempty" form:"Capacity" json:"Capacity,omitempty" query:"Capacity"`
	// 资源已使用数量
	Used int64 `bson:"used,omitempty" form:"Used" json:"Used,omitempty" query:"Used"`
}

resource quota

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL