Documentation ¶
Index ¶
- Constants
- Variables
- func GetUsersUID(users []User) []string
- func ToRuleObject(kind, rule string) interface{}
- type Group
- type GroupLabel
- type GroupSetting
- type Label
- type LabelRule
- type Lock
- type Module
- type MyLabelInfo
- type PercentRule
- type Product
- type Setting
- type SettingRule
- type Statistic
- type StatisticKey
- type User
- type UserCache
- type UserCacheLabel
- type UserCacheLabelMap
- type UserGroup
- type UserLabel
- type UserSetting
Constants ¶
const ( // RuleUserPercent ... RuleUserPercent = "userPercent" // RuleNewUserPercent ... RuleNewUserPercent = "newUserPercent" // RuleChildLabelUserPercent parent-child relationship label RuleChildLabelUserPercent = "childLabelUserPercent" )
const TableGroup = "urbs_group"
TableGroup is a table name in db.
const TableGroupLabel = "group_label"
TableGroupLabel is a table name in db.
const TableGroupSetting = "group_setting"
TableGroupSetting is a table name in db.
const TableLabel = "urbs_label"
TableLabel is a table name in db.
const TableLabelRule = "label_rule"
TableLabelRule is a table name in db.
const TableLock = "urbs_lock"
TableLock is a table name in db.
const TableModule = "urbs_module"
TableModule is a table name in db.
const TableProduct = "urbs_product"
TableProduct is a table name in db.
const TableSetting = "urbs_setting"
TableSetting is a table name in db.
const TableSettingRule = "setting_rule"
TableSettingRule is a table name in db.
const TableStatistic = "urbs_statistic"
TableStatistic is a table name in db.
const TableUser = "urbs_user"
TableUser is a table name in db.
const TableUserGroup = "user_group"
TableUserGroup is a table name in db.
const TableUserLabel = "user_label"
TableUserLabel is a table name in db.
const TableUserSetting = "user_setting"
TableUserSetting is a table name in db.
Variables ¶
var ( // RuleKinds ... RuleKinds = []string{RuleUserPercent, RuleNewUserPercent, RuleChildLabelUserPercent} )
Functions ¶
func GetUsersUID ¶ added in v1.1.0
GetUsersUID 返回 users 数组的 uid 数组
func ToRuleObject ¶ added in v1.3.0
func ToRuleObject(kind, rule string) interface{}
ToRuleObject ...
Types ¶
type Group ¶
type Group struct { ID int64 `db:"id" json:"-" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" json:"createdAt" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt" goqu:"skipinsert"` SyncAt int64 `db:"sync_at" json:"syncAt"` // 群组成员同步时间点,1970 以来的秒数 UID string `db:"uid" json:"uid"` // varchar(63),群组外部ID,表内唯一, 如 Teambition organization id Kind string `db:"kind" json:"kind"` // varchar(63),群组外部ID,表内唯一, 如 Teambition organization id Desc string `db:"description" json:"desc"` // varchar(1022),群组描述 Status int64 `db:"status" json:"status" db:"status"` // 成员计数(被动异步计算,非精确值) }
Group 详见 ./sql/schema.sql table `urbs_group` 用户群组
type GroupLabel ¶
type GroupLabel struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` GroupID int64 `db:"group_id"` // 群组内部 ID LabelID int64 `db:"label_id"` // 环境标签内部 ID Release int64 `db:"rls"` // 标签被设置计数批次 }
GroupLabel 详见 ./sql/schema.sql table `group_label` 记录群组被设置的环境标签,将作用于群组所有成员
type GroupSetting ¶
type GroupSetting struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` GroupID int64 `db:"group_id"` // 群组内部 ID SettingID int64 `db:"setting_id"` // 配置项内部 ID Value string `db:"value"` // varchar(255),配置值 LastValue string `db:"last_value"` // varchar(255),上一次配置值 Release int64 `db:"rls"` // 配置项被设置计数批次 }
GroupSetting 详见 ./sql/schema.sql table `group_setting` 记录群组对某功能模块配置项值,将作用于群组所有成员
type Label ¶
type Label struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` OfflineAt *time.Time `db:"offline_at"` // 计划下线时间,用于灰度管理 ProductID int64 `db:"product_id"` // 所从属的产品线 ID Name string `db:"name"` // varchar(63) 环境标签名称,产品线内唯一 Desc string `db:"description"` // varchar(1022) 环境标签描述 Channels string `db:"channels"` // varchar(255) 标签适用的版本通道,未配置表示都适用 Clients string `db:"clients"` // varchar(255) 标签适用的客户端类型,未配置表示都适用 Status int64 `db:"status"` // -1 下线弃用,使用用户计数(被动异步计算,非精确值) Release int64 `db:"rls"` // 标签发布(被设置)计数 }
Label 详见 ./sql/schema.sql table `urbs_label` 环境标签
type LabelRule ¶ added in v1.3.0
type LabelRule struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` ProductID int64 `db:"product_id"` // 所从属的产品线 ID,与环境标签的产品线一致 LabelID int64 `db:"label_id"` // 规则所指向的环境标签 ID Kind string `db:"kind"` // 规则类型 Rule string `db:"rule"` // varchar(1022),规则值,JSON string,对于 percent 类,其格式为 {"value": percent} Release int64 `db:"rls"` // 标签发布(被设置)计数批次 }
LabelRule 详见 ./sql/schema.sql table `label_rule` 环境标签发布规则
type Lock ¶ added in v1.3.0
type Lock struct { ID int64 `db:"id" goqu:"skipinsert"` Name string `db:"name"` // varchar(255) 锁键,表内唯一 ExpireAt time.Time `db:"expire_at"` }
Lock 详见 ./sql/schema.sql table `urbs_lock` 内部锁
type Module ¶
type Module struct { ID int64 `db:"id" json:"-" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" json:"createdAt" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt" goqu:"skipinsert"` OfflineAt *time.Time `db:"offline_at" json:"offlineAt"` // 计划下线时间,用于灰度管理 ProductID int64 `db:"product_id"` // 所从属的产品线 ID Name string `db:"name" json:"name"` // varchar(63) 功能模块名称,产品线内唯一 Desc string `db:"description" json:"desc"` // varchar(1022) 功能模块描述 Status int64 `db:"status" json:"status"` // -1 下线弃用,有效配置项计数(被动异步计算,非精确值) }
Module 详见 ./sql/schema.sql table `urbs_module` 产品线的功能模块
type MyLabelInfo ¶ added in v1.4.0
type MyLabelInfo struct { ID int64 `db:"id"` CreatedAt time.Time `db:"created_at"` Name string `db:"name"` Channels string `db:"channels"` Clients string `db:"clients"` Product string `db:"product"` }
MyLabelInfo ...
type PercentRule ¶ added in v1.3.0
type PercentRule struct { Kind string `json:"kind"` Rule struct { Value int `json:"value"` } `json:"rule"` }
PercentRule ...
func ToPercentRule ¶ added in v1.3.0
func ToPercentRule(kind, rule string) *PercentRule
ToPercentRule ...
type Product ¶
type Product struct { ID int64 `db:"id" json:"-" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" json:"createdAt" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt" goqu:"skipinsert"` DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"` // 删除时间,用于灰度管理 OfflineAt *time.Time `db:"offline_at" json:"offlineAt"` // 下线时间,用于灰度管理 Name string `db:"name" json:"name"` // varchar(63) 产品线名称,表内唯一 Desc string `db:"description" json:"desc"` // varchar(1022) 产品线描述 Status int64 `db:"status" json:"status"` // -1 下线弃用,未使用 }
Product 详见 ./sql/schema.sql table `urbs_product` 产品线
type Setting ¶
type Setting struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` OfflineAt *time.Time `db:"offline_at"` // 计划下线时间,用于灰度管理 ModuleID int64 `db:"module_id"` // 配置项所从属的功能模块 ID Module string `db:"module" goqu:"skipinsert"` // 仅为查询方便追加字段,数据库中没有该字段 Name string `db:"name"` // varchar(63) 配置项名称,功能模块内唯一 Desc string `db:"description"` // varchar(1022) 配置项描述信息 Channels string `db:"channels"` // varchar(255) 配置项适用的版本通道,未配置表示都适用 Clients string `db:"clients"` // varchar(255) 配置项适用的客户端类型,未配置表示都适用 Values string `db:"vals"` // varchar(1022) 配置项可选值集合 Status int64 `db:"status"` // -1 下线弃用,使用用户计数(被动异步计算,非精确值) Release int64 `db:"rls"` // 配置项发布(被设置)计数 }
Setting 详见 ./sql/schema.sql table `urbs_setting` 功能模块的配置项
type SettingRule ¶ added in v1.3.0
type SettingRule struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` ProductID int64 `db:"product_id"` // 所从属的产品线 ID,与环境标签的产品线一致 SettingID int64 `db:"setting_id"` // 规则所指向的环境标签 ID Kind string `db:"kind"` // 规则类型 Rule string `db:"rule"` // varchar(1022),规则值,JSON string,对于 percent 类,其格式为 {"value": percent} Value string `db:"value"` // varchar(255),配置值 Release int64 `db:"rls"` // 标签发布(被设置)计数批次 }
SettingRule 详见 ./sql/schema.sql table `setting_rule` 环境标签发布规则
func (SettingRule) TableName ¶ added in v1.3.0
func (SettingRule) TableName() string
TableName retuns table name
func (SettingRule) ToPercent ¶ added in v1.3.0
func (l SettingRule) ToPercent() int
ToPercent retuns table name
type Statistic ¶ added in v1.3.0
type Statistic struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` Name string `db:"name"` // varchar(255) 锁键,表内唯一 Status int64 `db:"status"` Value string `db:"value"` // varchar(8190) json value }
Statistic 详见 ./sql/schema.sql table `urbs_statistic` 内部统计
type StatisticKey ¶ added in v1.3.0
type StatisticKey string
StatisticKey ...
const ( UsersTotalSize StatisticKey = "UsersTotalSize" GroupsTotalSize StatisticKey = "GroupsTotalSize" ProductsTotalSize StatisticKey = "ProductsTotalSize" LabelsTotalSize StatisticKey = "LabelsTotalSize" ModulesTotalSize StatisticKey = "ModulesTotalSize" SettingsTotalSize StatisticKey = "SettingsTotalSize" LabelRulesTotalSize StatisticKey = "LabelRulesTotalSize" SettingRulesTotalSize StatisticKey = "SettingRulesTotalSize" )
UsersTotalSize ...
type User ¶
type User struct { ID int64 `db:"id" json:"-" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" json:"createdAt" goqu:"skipinsert"` UID string `db:"uid" json:"uid"` // varchar(63),用户外部ID,表内唯一, 如 Teambition user id ActiveAt int64 `db:"active_at" json:"activeAt"` // 最近活跃时间戳,1970 以来的秒数,但不及时更新 Labels string `db:"labels" json:"labels"` // varchar(8190),缓存用户当前被设置的 labels }
User 详见 ./sql/schema.sql table `urbs_user` 记录用户外部唯一 ID,uid 和最近活跃时间 缓存用户当前全部 label,根据 active_at 和 cache_label_expire 刷新 labels 格式:TODO
func (*User) GetCacheMap ¶ added in v1.10.0
func (u *User) GetCacheMap() UserCacheLabelMap
GetCacheMap 从 user 上读取结构化的缓存数据
func (*User) GetLabels ¶
func (u *User) GetLabels(product string) []UserCacheLabel
GetLabels 从 user 上读取结构化的 labels 数据
func (*User) PutCacheMap ¶ added in v1.10.0
func (u *User) PutCacheMap(labels UserCacheLabelMap) error
PutCacheMap 把结构化的 labels 数据转成字符串设置在 user.Labels 上
type UserCache ¶ added in v1.10.0
type UserCache struct { ActiveAt int64 `json:"activeAt"` // 最近活跃时间戳,1970 以来的秒数,但不及时更新 Labels []UserCacheLabel `json:"labels"` }
UserCache 用于在 User 数据上缓存数据
type UserCacheLabel ¶
type UserCacheLabel struct { Label string `json:"l"` Clients []string `json:"cls,omitempty"` Channels []string `json:"chs,omitempty"` }
UserCacheLabel 用于在 User 数据上缓存 labels
type UserCacheLabelMap ¶ added in v1.10.0
UserCacheLabelMap 用于在 User 数据上缓存
type UserGroup ¶
type UserGroup struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` SyncAt int64 `db:"sync_at"` // 归属关系同步时间戳,1970 以来的秒数,应该与 group.sync_at 相等 UserID int64 `db:"user_id"` // 用户内部 ID GroupID int64 `db:"group_id"` // 群组内部 ID }
UserGroup 详见 ./sql/schema.sql table `user_group` 记录用户从属的群组,用户可以归属到多个群组 用户能从所归属的群组继承环境标签和功能项配置,也就是基于群组进行灰度
type UserLabel ¶
type UserLabel struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UserID int64 `db:"user_id"` // 用户内部 ID LabelID int64 `db:"label_id"` // 环境标签内部 ID Release int64 `db:"rls"` // 标签被设置计数批次 }
UserLabel 详见 ./sql/schema.sql table `user_label` 记录用户被分配的环境标签,不同客户端不同大版本可能有不同的环境标签
type UserSetting ¶
type UserSetting struct { ID int64 `db:"id" goqu:"skipinsert"` CreatedAt time.Time `db:"created_at" goqu:"skipinsert"` UpdatedAt time.Time `db:"updated_at" goqu:"skipinsert"` UserID int64 `db:"user_id"` // 用户内部 ID SettingID int64 `db:"setting_id"` // 配置项内部 ID Value string `db:"value"` // varchar(255),配置值 LastValue string `db:"last_value"` // varchar(255),上一次配置值 Release int64 `db:"rls"` // 配置项被设置计数批次 }
UserSetting 详见 ./sql/schema.sql table `user_setting` 记录用户对某功能模块配置项值