Documentation ¶
Index ¶
- Constants
- func AppName(name string) utils.OptionFunc[useOption]
- func Construct(ctx context.Context, confs map[string]*Conf, opts ...utils.OptionExtender) func()
- func Expire(expired time.Duration) utils.OptionFunc[lockOption]
- func ReentrantKey(key string) utils.OptionFunc[lockOption]
- func Within(ctx context.Context, locker Lockable, key string, ...) (err error)
- type Conf
- type Lockable
- type ReentrantLockable
Constants ¶
View Source
const ( ErrDuplicatedName utils.Error = "duplicated lock name" ErrUnsupportedLockType utils.Error = "unsupported lock type" ErrReentrantKeyNotFound utils.Error = "reentrant key for lock not found" ErrTimeout utils.Error = "try to lock timeout" ErrContextDone utils.Error = "try to lock when context done" )
Variables ¶
This section is empty.
Functions ¶
func AppName ¶
func AppName(name string) utils.OptionFunc[useOption]
func ReentrantKey ¶
func ReentrantKey(key string) utils.OptionFunc[lockOption]
Types ¶
type Conf ¶
type Conf struct { Type lockType `yaml:"type" json:"type" toml:"type"` Instance string `yaml:"instance" json:"instance" toml:"instance"` Scheme string `yaml:"scheme" json:"scheme" toml:"scheme"` }
Conf lock configure
type Lockable ¶
type ReentrantLockable ¶
type ReentrantLockable interface { Lockable ReentrantLock(ctx context.Context, key, reentrantKey string, opts ...utils.OptionExtender) (err error) }
func UseReentrant ¶
func UseReentrant(ctx context.Context, name string, opts ...utils.OptionExtender) ReentrantLockable
Source Files ¶
Click to show internal directories.
Click to hide internal directories.