Documentation
¶
Index ¶
- Variables
- func DoMigration(name string, m MigrationMap) error
- func GetCurrentVersion(name string) int64
- func SetVersion(name string, version int64) (oldVersion int64, err error)
- type Migration
- type MigrationFunc
- func ChainMigration(fn ...MigrationFunc) MigrationFunc
- func CopyKeyValueByPattern(patternFunc localdb.KeyPatternFunc, ...) MigrationFunc
- func MigrationKeyValueByPattern(patternFunc localdb.KeyPatternFunc, ...) MigrationFunc
- func MigrationValueByPattern(patternFunc localdb.KeyPatternFunc, operator func(key, value string) string) MigrationFunc
- type MigrationMap
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownVersion = errors.New("version is unknown")
Functions ¶
func DoMigration ¶
func DoMigration(name string, m MigrationMap) error
func GetCurrentVersion ¶
Types ¶
type Migration ¶
type Migration interface { Func() MigrationFunc TargetVersion() int64 }
func CreateSimpleMigration ¶
func CreateSimpleMigration(targetVersion int64, f MigrationFunc) Migration
CreateSimpleMigration 可以用来快速创建一个 Migration 的helper 如果逻辑较为复杂,需要其他更多信息,也可以自行实现 Migration
type MigrationFunc ¶
type MigrationFunc func() error
MigrationFunc 定义了迁移函数,实现的时候只能在当前goroutine内操作,不可创建其他goroutine,执行时会在RW事务中
func ChainMigration ¶
func ChainMigration(fn ...MigrationFunc) MigrationFunc
ChainMigration 将多个 MigrationFunc 组合成一个 MigrationFunc ,每个 MigrationFunc 会按顺序执行
func CopyKeyValueByPattern ¶
func CopyKeyValueByPattern(patternFunc localdb.KeyPatternFunc, operator func(key, value string) (string, string)) MigrationFunc
CopyKeyValueByPattern 遍历一个KeyPattern,对每个key/value执行operator,并把operator的返回值作为新的key/value,保留TTL 如果key变化了,不会删除老的key
func MigrationKeyValueByPattern ¶
func MigrationKeyValueByPattern(patternFunc localdb.KeyPatternFunc, operator func(key, value string) (string, string)) MigrationFunc
MigrationKeyValueByPattern 遍历一个KeyPattern,对每个key/value执行operator,并把operator的返回值作为新的key/value,保留TTL 如果key变化了,会删除老的key
func MigrationValueByPattern ¶
func MigrationValueByPattern(patternFunc localdb.KeyPatternFunc, operator func(key, value string) string) MigrationFunc
MigrationValueByPattern 遍历一个KeyPattern,对每个key/value执行operator,并把operator的返回值作为新的value,保留TTL
type MigrationMap ¶
func NewMigrationMapFromMap ¶
func NewMigrationMapFromMap(m map[int64]Migration) MigrationMap
Click to show internal directories.
Click to hide internal directories.