provider

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

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 DbTime

type DbTime time.Time

func (DbTime) MarshalText

func (dt DbTime) MarshalText() (data []byte, err error)

func (*DbTime) Scan

func (dt *DbTime) Scan(value interface{}) error

func (*DbTime) UnmarshalText

func (dt *DbTime) UnmarshalText(text []byte) (err error)

func (DbTime) Value

func (dt DbTime) Value() (driver.Value, error)

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"`
}

func (LockModel) TableName

func (LockModel) TableName() string

Jump to

Keyboard shortcuts

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