schema

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// RuleUserPercent ...
	RuleUserPercent = "userPercent"
	// RuleNewUserPercent ...
	RuleNewUserPercent = "newUserPercent"
	// RuleChildLabelUserPercent parent-child relationship label
	RuleChildLabelUserPercent = "childLabelUserPercent"
)
View Source
const TableGroup = "urbs_group"

TableGroup is a table name in db.

View Source
const TableGroupLabel = "group_label"

TableGroupLabel is a table name in db.

View Source
const TableGroupSetting = "group_setting"

TableGroupSetting is a table name in db.

View Source
const TableLabel = "urbs_label"

TableLabel is a table name in db.

View Source
const TableLabelRule = "label_rule"

TableLabelRule is a table name in db.

View Source
const TableLock = "urbs_lock"

TableLock is a table name in db.

View Source
const TableModule = "urbs_module"

TableModule is a table name in db.

View Source
const TableProduct = "urbs_product"

TableProduct is a table name in db.

View Source
const TableSetting = "urbs_setting"

TableSetting is a table name in db.

View Source
const TableSettingRule = "setting_rule"

TableSettingRule is a table name in db.

View Source
const TableStatistic = "urbs_statistic"

TableStatistic is a table name in db.

View Source
const TableUser = "urbs_user"

TableUser is a table name in db.

View Source
const TableUserGroup = "user_group"

TableUserGroup is a table name in db.

View Source
const TableUserLabel = "user_label"

TableUserLabel is a table name in db.

View Source
const TableUserSetting = "user_setting"

TableUserSetting is a table name in db.

Variables

Functions

func GetUsersUID added in v1.1.0

func GetUsersUID(users []User) []string

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` 用户群组

func (Group) TableName added in v1.0.0

func (Group) TableName() string

TableName retuns table name

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` 环境标签

func (Label) TableName added in v1.0.0

func (Label) TableName() string

TableName retuns table name

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` 环境标签发布规则

func (LabelRule) TableName added in v1.3.0

func (LabelRule) TableName() string

TableName retuns table name

func (LabelRule) ToPercent added in v1.3.0

func (l LabelRule) ToPercent() int

ToPercent retuns table name

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` 内部锁

func (Lock) TableName added in v1.3.0

func (Lock) TableName() string

TableName retuns table name

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` 产品线的功能模块

func (Module) TableName added in v1.0.0

func (Module) TableName() string

TableName retuns table name

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 ...

func (*PercentRule) ToRule added in v1.3.0

func (r *PercentRule) ToRule() string

ToRule ...

func (*PercentRule) Validate added in v1.3.0

func (r *PercentRule) Validate() error

Validate ...

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` 产品线

func (Product) TableName added in v1.0.0

func (Product) TableName() string

TableName retuns table name

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` 功能模块的配置项

func (Setting) TableName added in v1.0.0

func (Setting) TableName() string

TableName retuns table name

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` 内部统计

func (Statistic) TableName added in v1.3.0

func (Statistic) TableName() string

TableName retuns table name

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) GetCache added in v1.10.0

func (u *User) GetCache(product string) *UserCache

GetCache 从 user 上读取结构化的缓存数据

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 上

func (User) TableName added in v1.0.0

func (User) TableName() string

TableName retuns table name

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

type UserCacheLabelMap map[string]*UserCache

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` 记录用户对某功能模块配置项值

Jump to

Keyboard shortcuts

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