upgrader

package
v0.0.0-...-cb472e6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const SystemTypeVersion = "version"
View Source
const VersionNgPrefix = "y"

Variables

View Source
var LegacyMigrationVersion = []string{
	"v3.0.8",
	"v3.0.9-beta.1",
	"v3.0.9-beta.3",
	"v3.1.0-alpha.2",
	"x08.09.04.01",
	"x08.09.11.01",
	"x08.09.13.01",
	"x08.09.17.01",
	"x08.09.18.01",
	"x08.09.26.01",
	"x18.09.30.01",
	"x18.10.10.01",
	"x18.10.30.01",
	"x18.10.30.02",
	"x18.11.19.01",
	"x18.12.12.01",
	"x18.12.12.02",
	"x18.12.12.03",
	"x18.12.12.04",
	"x18.12.12.05",
	"x18.12.12.06",
	"x18.12.13.01",
	"x18_12_13_02",
	"x19.01.18.01",
	"x19.02.15.10",
	"x19.04.16.01",
	"x19.04.16.02",
	"x19.04.16.03",
	"x19.05.16.01",
	"x19_05_22_01",
	"x19_08_19_01",
	"x19_08_20_01",
	"x19_08_26_01",
	"x19_08_26_02",
	"x19_09_03_01",
	"x19_09_03_02",
	"x19_09_03_03",
	"x19_09_03_04",
	"x19_09_03_05",
	"x19_09_03_06",
	"x19_09_03_07",
	"x19_09_03_08",
	"x19_09_06_01",
	"x19_09_27_01",
	"x19_10_09_01",
	"x19_10_22_01",
}
View Source
var PatchRegex = regexp.MustCompile(`^\d{12}$`)
View Source
var ValidMigrationVersionFormat = []*regexp.Regexp{

	regexp.MustCompile(`^x(\d+_){3}\d+$`),

	regexp.MustCompile(`^y(\d+\.){2}\d{12}$`),
}

Functions

func Insert

func Insert(ctx context.Context, db dal.RDB, tableName string, row interface{}, idField string, uniqueKeys []string) error

Insert insert the row to db if it doesn't exist, else do nothing row is the data to insert idField used to be field name of generated instance id uniqueKeys used to judge whether the row exist in db

func Int64Compare

func Int64Compare(val1, val2 int64) int

func RegistUpgrader

func RegistUpgrader(version string, handlerFunc func(context.Context, dal.RDB, *Config) error)

RegistUpgrader register upgrader

func RegisterUpgraderWithRedis

func RegisterUpgraderWithRedis(version string, handlerFunc func(context.Context, dal.RDB, *redis.Client, *Config) error)

RegisterUpgraderWithRedis register upgrader with redis

func StringCompare

func StringCompare(s1, s2 string) int

func Upgrade

func Upgrade(ctx context.Context, db dal.RDB, cache *redis.Client, conf *Config) (currentVersion string, finishedMigrations []string, err error)

Upgrade upgrade the db data to newest version we use date instead of version later since 2018.09.04, because the version wasn't manage by the developer ps: when use date instead of version, the date should add x prefix cause x > v

func UpgradeConfigAdmin

func UpgradeConfigAdmin(ctx context.Context, db dal.RDB) error

UpgradeConfigAdmin 升级配置管理 每次升级变更配置,需要在configChangeHistory最后追加一项要变更的配置 将configChangeHistory里的最后一项作为当前配置项curCfg,倒数第二项作为上一次配置项preCfg 需要将preCfg和db存在的配置dbCfg进行对比,对于不一致的(说明有用户调过配置管理接口做过更改),curCfg里对应的配置不做覆盖,仍为db里的数据

func Upsert

func Upsert(ctx context.Context, db dal.RDB, tableName string, row interface{}, idField string, uniqueKeys []string, ignores []string) (instID uint64, preData map[string]interface{}, err error)

Upsert inset row but update it without ignores key if exists same value with keys

func V36VersionCmp

func V36VersionCmp(version1, version2 string) int

func ValidateMigrationVersionFormat

func ValidateMigrationVersionFormat(version string) error

func VersionCmp

func VersionCmp(version1, version2 string) int

Types

type Config

type Config struct {
	OwnerID      string
	User         string
	CCApiSrvAddr string // cmdb nginx address
}

Config config for upgrader

type NgVersion

type NgVersion struct {
	Major int64
	Minor int64
	Patch string
}

func ParseNgVersion

func ParseNgVersion(version string) (NgVersion, error)

type System

type System struct {
	Type string `bson:"type"`
}

type Upgrader

type Upgrader struct {
	// contains filtered or unexported fields
}

Upgrader define a version upgrader

type Version

type Version struct {
	System            `bson:",inline"`
	CurrentVersion    string `bson:"current_version"`
	Distro            string `bson:"distro"`
	DistroVersion     string `bson:"distro_version"`
	InitVersion       string `bson:"init_version"`
	InitDistroVersion string `bson:"init_distro_version"`
}

Directories

Path Synopsis
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Tencent is pleased to support the open source community by making 蓝鲸 available.

Jump to

Keyboard shortcuts

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