Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrConflict = errors.New("LockConflict")
)
Functions ¶
This section is empty.
Types ¶
type DBLock ¶
type DBLock struct {
// contains filtered or unexported fields
}
type ResourceLock ¶
type ResourceLock struct {
ID uint `gorm:"primarykey;AUTO_INCREMENT"`
Resource string `gorm:"type:varchar(255);unique"`
// 假设一种情况,A请求拿到了锁,但是本身任务太长,超过了锁时间,B请求拿到了锁,并且开始执行任务,A任务完成了会去解锁,这个时候就意外地把B刚拿到的锁解了
// Lock成功应该生成一个所有者ID,保存到表里面并且返回,unlock的时候需要指定这个所有者ID匹配了去解锁,这样可以防止解锁了其他人的锁
LockerID string `gorm:"type:varchar(255);index:idx_locker_id"`
CreatedAt time.Time
UpdatedAt time.Time
}
ResourceLock is the model of ResourceLock.
func (ResourceLock) TableName ¶
func (ResourceLock) TableName() string
TableName returns the table name of the Partition.
Click to show internal directories.
Click to hide internal directories.