mutex

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 9 Imported by: 4

README

mutex

infra.Go mutex module.

Documentation

Index

Constants

View Source
const (
	NAME    = "MUTEX"
	DEFAULT = "default"
)

Variables

View Source
var (
	ErrInvalidConnection = errors.New("Invalid mutex connection.")
)

Functions

func Key

func Key(args ...Any) string

func Lock

func Lock(args ...Any) (*locker, error)

func LockOn

func LockOn(conn string, args ...Any) (*locker, error)

func Locked

func Locked(args ...Any) bool

func LockedOn

func LockedOn(conn string, args ...Any) bool

func Unlock

func Unlock(args ...Any) error

func UnlockOn

func UnlockOn(conn string, args ...Any) error

Types

type Config

type Config struct {
	Driver  string
	Weight  int
	Prefix  string
	Expiry  time.Duration
	Setting Map
}

type Configs

type Configs map[string]Config

type Connect

type Connect interface {
	//打开、关闭
	Open() error
	Close() error

	Lock(key string, expires time.Duration) error
	Unlock(key string) error
}

Connect 连接

type Driver

type Driver interface {
	Connect(*Instance) (Connect, error)
}

Driver 驱动

type Instance

type Instance struct {
	Name    string
	Config  Config
	Setting Map
	// contains filtered or unexported fields
}

type Module

type Module struct {
	// contains filtered or unexported fields
}

func (*Module) Config

func (this *Module) Config(name string, config Config)

func (*Module) Configs

func (this *Module) Configs(config Configs)

func (*Module) Configure

func (this *Module) Configure(global Map)

func (*Module) Connect

func (this *Module) Connect()

func (*Module) Driver

func (module *Module) Driver(name string, driver Driver)

Driver 注册驱动

func (*Module) Initialize

func (this *Module) Initialize()

func (*Module) Launch

func (this *Module) Launch()

func (*Module) Lock

func (this *Module) Lock(key string, expiries ...time.Duration) error

Lock 加锁

func (*Module) LockOn

func (this *Module) LockOn(conn string, key string, expiries ...time.Duration) error

LockTo 加锁到指定的连接

func (*Module) Register

func (this *Module) Register(name string, value Any)

func (*Module) Terminate

func (this *Module) Terminate()

func (*Module) Unlock

func (this *Module) Unlock(conn, key string) error

Unlock 解锁

func (*Module) UnlockOn

func (this *Module) UnlockOn(conn, key string) error

UnlockOn 指定库解锁

Jump to

Keyboard shortcuts

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