Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface {
Acquire(ctx context.Context, tx *sql.Tx, account, region, resource string, cycle Cycle, max, n int64) error
Release(ctx context.Context, tx *sql.Tx, account, region, resource string, cycle Cycle, capacity, n int64) error
Set(ctx context.Context, tx *sql.Tx, account, region, resource string, cycle Cycle, capacity, used int64) error
List(ctx context.Context, account, region string, cycle Cycle, resource []string) ([]*Quota, 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"`
}
Quota represents the resource quota data.
The corresponding table can be created with the following SQL:
CREATE TABLE `quota` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key', `account` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'account identifier', `region` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'region the resource belongs to', `resource` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'resource name', `cycle` VARCHAR(8) NOT NULL DEFAULT '' COMMENT 'current cycle identity, e.g. 20060102', `capacity` BIGINT NOT NULL DEFAULT 0 COMMENT 'total capacity of the resource', `used` BIGINT NOT NULL DEFAULT 0 COMMENT 'used amount of the resource', `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'created time', `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'updated time', PRIMARY KEY (`account`, `region`, `resource`, `cycle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='resource quota records';
Click to show internal directories.
Click to hide internal directories.