lock

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close 关闭构建器

func SetMaker

func SetMaker(maker Maker)

SetMaker 设置Locker制造商

Types

type Locker

type Locker interface {
	// Acquire 获取锁
	Acquire(ctx context.Context) error
	// TryAcquire 尝试获取锁
	TryAcquire(ctx context.Context, expiration ...time.Duration) error
	// Release 释放锁
	Release(ctx context.Context) error
}

func Make

func Make(name string) Locker

Make 制造一个Locker

type Maker

type Maker interface {
	// Make 制造一个Locker
	Make(name string) Locker
	// Close 关闭构建器
	Close() error
}

func GetMaker

func GetMaker() Maker

GetMaker 获取Locker制造商

type Option

type Option struct {
	Once       bool          // 是否仅获取一次;默认阻塞地获取,直到获取成功
	Expiration time.Duration //
}

Jump to

Keyboard shortcuts

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