locker

package
v0.0.0-...-80b3c92 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 7 Imported by: 0

README

package locker : 排他锁的解决方案
当前配置里 设置 exclusive = true 适用

1、Local.go : 本地锁   依赖当前机器的sync.Mutex{}
2、Redis.go :分布式锁  依赖于部署redis服务

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelLocker

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

func (*ChannelLocker) AddLock

func (c *ChannelLocker) AddLock() error

func (*ChannelLocker) UnLock

func (c *ChannelLocker) UnLock() error

type Locker

type Locker interface {
	AddLock() error //加锁
	UnLock() error  //解锁
}

定义Locker接口

type MutexLocker

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

func (*MutexLocker) AddLock

func (local *MutexLocker) AddLock() error

func (*MutexLocker) UnLock

func (local *MutexLocker) UnLock() error

type MyTasksLocker

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

任务锁,当计划任务里设置exclusive = true时使用

func NewMyTasksLocker

func NewMyTasksLocker(config types.TomlConfig) *MyTasksLocker

提供任务锁对象指针

func (*MyTasksLocker) GetTaskLocker

func (mtl *MyTasksLocker) GetTaskLocker(taskName string) Locker

type RedisLocker

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

func NewRedisLocker

func NewRedisLocker(addr string, password string, db int, taskName string, lockerWait bool) *RedisLocker

func (*RedisLocker) AddLock

func (rd *RedisLocker) AddLock() error

func (*RedisLocker) UnLock

func (rd *RedisLocker) UnLock() error

Jump to

Keyboard shortcuts

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