lock

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 6 Imported by: 0

README

mysql-lock

a simple distributed lock based on mysql

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMySQL

func InitMySQL(dsn string, debug bool) *gorm.DB

Types

type LockStore

type LockStore struct {
	Name      string    `gorm:"column:name;size:100;index:uni_name,unique" json:"name"`
	CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
	// other
	ID int `gorm:"column:id" json:"id"`
}

func (LockStore) TableName

func (LockStore) TableName() string

type MySQLLock

type MySQLLock struct {
	MySQLClient *gorm.DB
	TXMap       map[string]*gorm.DB
}

func NewMySQLLock

func NewMySQLLock(dsn string, debug bool) *MySQLLock

func (*MySQLLock) Acquire

func (l *MySQLLock) Acquire(lockName string, wait time.Duration) error

Lock :If the lock cannot be obtained, it will keep blocking

func (*MySQLLock) Init

func (l *MySQLLock) Init(lockNameList []string)

Init :Create tables Create row record

func (*MySQLLock) Release

func (l *MySQLLock) Release(lockName string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL