Documentation
¶
Index ¶
Constants ¶
View Source
const ( LockStatusOpen = 0 LockStatusClosed = 1 )
Variables ¶
This section is empty.
Functions ¶
func InitMySQLWithConn ¶ added in v0.0.4
initialize *gorm.DB with an existing database connection
Types ¶
type LockCounter ¶ added in v0.0.4
type LockCounter struct {
Name string `gorm:"column:name;size:100;index:uni_name,unique" json:"name"`
Owner string `gorm:"column:owner;size:100" json:"owner"`
Counter uint64 `gorm:"column:counter" json:"counter"`
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
ModifiedAt time.Time `gorm:"column:modified_at" json:"modifiedAt"`
// other
ID int `gorm:"column:id" json:"id"`
}
func (LockCounter) TableName ¶ added in v0.0.4
func (LockCounter) TableName() string
type LockStore ¶
type MySQCounterLock ¶ added in v0.0.4
func (*MySQCounterLock) Acquire ¶ added in v0.0.4
func (l *MySQCounterLock) Acquire(lockName string, wait time.Duration) error
Lock :If the lock cannot be obtained, it will keep blocking wait: < 0 no wait
func (*MySQCounterLock) Init ¶ added in v0.0.4
func (l *MySQCounterLock) Init(lockNameList []string)
Init :Create tables
func (*MySQCounterLock) Release ¶ added in v0.0.4
func (l *MySQCounterLock) Release(lockName string) error
type MySQLLockItf ¶ added in v0.0.4
type MySQLLockItf interface {
Init(lockNameList []string)
Acquire(lockName string, wait time.Duration) error
Release(lockName string) error
}
func NewCounterLockWithConn ¶ added in v0.0.4
func NewCounterLockWithConn(db *sql.DB) MySQLLockItf
func NewCounterLockWithDSN ¶ added in v0.0.4
func NewCounterLockWithDSN(dsn string, debug bool) MySQLLockItf
func NewRowLockWithConn ¶ added in v0.0.4
func NewRowLockWithConn(db *sql.DB) MySQLLockItf
func NewRowLockWithDSN ¶ added in v0.0.4
func NewRowLockWithDSN(dsn string, debug bool) MySQLLockItf
type MySQRowLLock ¶ added in v0.0.4
func (*MySQRowLLock) Acquire ¶ added in v0.0.4
func (l *MySQRowLLock) Acquire(lockName string, wait time.Duration) error
Lock :If the lock cannot be obtained, it will keep blocking
func (*MySQRowLLock) Init ¶ added in v0.0.4
func (l *MySQRowLLock) Init(lockNameList []string)
Init :Create tables Create row record
func (*MySQRowLLock) Release ¶ added in v0.0.4
func (l *MySQRowLLock) Release(lockName string) error
Click to show internal directories.
Click to hide internal directories.