Documentation ¶
Index ¶
- Constants
- Variables
- type DbVersionInfo
- type ILogger
- type IOptimisticLock
- type IVersionMag
- type IVersionMagV2
- type JwtTokenHandler
- type Lock
- type OptimisticLock
- type VersionMag
- func (this *VersionMag) AddLogger(logger logFunc)
- func (this *VersionMag) Label() string
- func (this *VersionMag) SetLabel(label string)
- func (this VersionMag) Upgrade(version string) error
- func (this *VersionMag) UpgradeOne(upVersion string, sqlFile string) error
- func (this VersionMag) Version() (string, error)
- type VersionMagV2
- func (this *VersionMagV2) AddLogger(logger logFunc)
- func (this *VersionMagV2) AppendSqlContent(version string, content string)
- func (this *VersionMagV2) AppendVersion(v DbVersionInfo)
- func (this *VersionMagV2) AppendVersionDir(sqlDir string) error
- func (this *VersionMagV2) Label() string
- func (this *VersionMagV2) SetLabel(label string)
- func (this *VersionMagV2) Upgrade(version string) error
- func (this *VersionMagV2) UpgradeOne(vInfo DbVersionInfo) error
- func (this VersionMagV2) Version() (string, error)
Constants ¶
View Source
const LOCK_TABLE = "lock_optimistic"
View Source
const STATUS_LOCK = 1
View Source
const STATUS_UNLOCK = 0
View Source
const VERSION_MAG_TABLE = "migrate_version"
Variables ¶
View Source
var CREATE_LOCK_TABLE_SQL = fmt.Sprintf(` CREATE TABLE IF NOT EXISTS %s ( id bigint unsigned NOT NULL AUTO_INCREMENT, lock_name varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '锁名', lock_at datetime DEFAULT NULL COMMENT '锁定时间', unlock_at datetime DEFAULT NULL COMMENT '解锁时间', lock_host varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '主机信息', timeout bigint unsigned default 0 COMMENT '超时时间,单位:秒', status int unsigned DEFAULT 0 COMMENT '锁状态,0:未锁定,1:已锁', PRIMARY KEY (id), UNIQUE KEY idx_lock (lock_name) ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='乐观锁表' `, LOCK_TABLE)
View Source
var CREATE_VERSION_TABLE_SQL = fmt.Sprintf(` CREATE TABLE IF NOT EXISTS %s ( id bigint unsigned NOT NULL AUTO_INCREMENT, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, label varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'label', version varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '版本号', upgrade_file varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '升级文件', PRIMARY KEY (id), UNIQUE KEY idx_version (label,version) ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='升级表' `, VERSION_MAG_TABLE)
Functions ¶
This section is empty.
Types ¶
type DbVersionInfo ¶ added in v1.1.10
type IOptimisticLock ¶
func NewOptimisticLock ¶
func NewOptimisticLock(db *sql.DB, timeout int64) (IOptimisticLock, error)
type IVersionMag ¶
type IVersionMag interface { Upgrade(version string) error UpgradeOne(version string, sqlFile string) error Version() (string, error) SetLabel(label string) Label() string ILogger }
func NewDBVersionMag ¶
func NewDBVersionMag(sqlDir string, db *sql.DB) (IVersionMag, error)
type IVersionMagV2 ¶ added in v1.1.10
type IVersionMagV2 interface { AppendVersionDir(sqlDir string) error AppendVersion(v DbVersionInfo) AppendSqlContent(version string, content string) Upgrade(version string) error UpgradeOne(vInfo DbVersionInfo) error Version() (string, error) SetLabel(label string) Label() string ILogger }
func NewDBVersionMagV2 ¶
func NewDBVersionMagV2(db *sql.DB) (IVersionMagV2, error)
type JwtTokenHandler ¶
type JwtTokenHandler struct {
SecretKey string
}
func NewJwtTokenHandler ¶ added in v1.1.8
func NewJwtTokenHandler(secret string) *JwtTokenHandler
func (*JwtTokenHandler) GetToken ¶
func (h *JwtTokenHandler) GetToken(data interface{}) (string, error)
func (*JwtTokenHandler) ParseToken ¶
func (h *JwtTokenHandler) ParseToken(data interface{}, token string) error
type Lock ¶
type OptimisticLock ¶
type OptimisticLock struct {
// contains filtered or unexported fields
}
func (*OptimisticLock) Lock ¶
func (this *OptimisticLock) Lock(name string) bool
func (*OptimisticLock) UnLock ¶
func (this *OptimisticLock) UnLock(name string) bool
type VersionMag ¶
type VersionMag struct {
// contains filtered or unexported fields
}
func (*VersionMag) AddLogger ¶
func (this *VersionMag) AddLogger(logger logFunc)
func (*VersionMag) Label ¶
func (this *VersionMag) Label() string
func (*VersionMag) SetLabel ¶
func (this *VersionMag) SetLabel(label string)
func (*VersionMag) UpgradeOne ¶
func (this *VersionMag) UpgradeOne(upVersion string, sqlFile string) error
升级一次版本
type VersionMagV2 ¶
type VersionMagV2 struct {
// contains filtered or unexported fields
}
func (*VersionMagV2) AddLogger ¶
func (this *VersionMagV2) AddLogger(logger logFunc)
func (*VersionMagV2) AppendSqlContent ¶ added in v1.1.10
func (this *VersionMagV2) AppendSqlContent(version string, content string)
func (*VersionMagV2) AppendVersion ¶ added in v1.1.10
func (this *VersionMagV2) AppendVersion(v DbVersionInfo)
func (*VersionMagV2) AppendVersionDir ¶ added in v1.1.10
func (this *VersionMagV2) AppendVersionDir(sqlDir string) error
func (*VersionMagV2) Label ¶
func (this *VersionMagV2) Label() string
func (*VersionMagV2) SetLabel ¶
func (this *VersionMagV2) SetLabel(label string)
func (*VersionMagV2) UpgradeOne ¶
func (this *VersionMagV2) UpgradeOne(vInfo DbVersionInfo) error
升级一次版本
Click to show internal directories.
Click to hide internal directories.