Documentation ¶
Overview ¶
provides simple distributed lock implemented by Mysql, which depends on Mysql table created in advance. User can custom table name, but should keep the same columns name as follows:
provider provides multiple lock implementation including mysql, redis etc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrEmptyName = errors.New("lock name empty")
)
Functions ¶
func NewMysqlLockProvider ¶
func NewMysqlLockProvider(db *gorm.DB) lock.LockProvider
Types ¶
type LockModel ¶
type LockModel struct { // ID is primary key normally. ID uint `gorm:"column:id;index;primaryKey;autoIncrement"` // Name is identifier of the lock, user can lock or unlock with specified name. Name string `gorm:"column:name"` // LockUntil is optional. If specified, the lock with hold until LockUntil arrives. LockUntil DbTime `gorm:"column:lock_until"` // LockAt is optional. If specified, LockAt DbTime `gorm:"column:locked_at"` // LockBy records the host ip currently holds the lock LockBy string `gorm:"column:locked_by"` }
Click to show internal directories.
Click to hide internal directories.