Files
orbit/platform/model/application_resources.go

39 lines
1.9 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"time"
core "git.yuntuo.hk/k2safe/orbit/model"
)
// ApplicationResources 是应用下全部命名空间和队列共享的额度与持久化用量。
// 独立于身份行,避免认证共享锁升级;不使用数据库外键。
type ApplicationResources struct {
// ApplicationID 所属应用标识,同时是主键;应用归属不可在线迁移。
ApplicationID core.ID `db:"application_id"`
// Revision 配置版本从 1 开始;用量变化不修改配置版本。
Revision uint64 `db:"revision"`
// CreatedAt 创建时间,UTC 微秒。
CreatedAt time.Time `db:"created_at"`
// UpdatedAt 最后配置变更时间,UTC 微秒;不是用量采样时间。
UpdatedAt time.Time `db:"updated_at"`
// MaxUnfinishedTasks 未终结任务上限;降额允许当前用量暂时高于上限。
MaxUnfinishedTasks uint32 `db:"max_unfinished_tasks"`
// UnfinishedTasks 等待、预占、运行和待核查的总数;重试不重复占用。
UnfinishedTasks uint64 `db:"unfinished_tasks"`
// MaxConcurrency 允许预占和运行的尝试总数;降额不撤销已有尝试。
MaxConcurrency uint32 `db:"max_concurrency"`
// ActiveAttempts 当前预占或运行的尝试数,到期恢复或结果确认时释放。
ActiveAttempts uint64 `db:"active_attempts"`
// PendingStarts 已预占但未开始的尝试数,属于 ActiveAttempts 的子集。
PendingStarts uint64 `db:"pending_starts"`
// RatePerSecond 一秒固定窗口允许的开始授权次数,不是业务 HTTP 请求限流。
RatePerSecond uint32 `db:"rate_per_second"`
// StartWindowUntil 数据库时间计算的窗口结束时刻;空表示尚未建立窗口。
StartWindowUntil *time.Time `db:"start_window_until"`
// StartsInWindow 当前窗口已确认的开始次数;回执重报不重复计数。
StartsInWindow uint32 `db:"starts_in_window"`
}
func (ApplicationResources) TableName() string { return "orbit_application_resources" }