mongoClient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(mongodbStr string) error

func Disconnect

func Disconnect()

func GetClient

func GetClient() *mongo.Client

Types

type Mutex

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

func CreateLock

func CreateLock(ctx context.Context, name string, timeout time.Duration) Mutex

创建一个分布式锁 timeout 锁的超时时间 name 锁名

func NewHostGpuLock

func NewHostGpuLock(ctx context.Context, hostId string, timeout time.Duration) Mutex

GpuLock

func NewHostNicLock

func NewHostNicLock(ctx context.Context, hostId string, timeout time.Duration) Mutex

NicLock

func (Mutex) GetLock

func (m Mutex) GetLock() (bool, error)

尝试获取锁

func (Mutex) Lock

func (m Mutex) Lock(interval, timeout time.Duration) error

*

  • @param interval 如果没有获取到,间隔interval时间段后再去尝试获取
  • @param timeout 如果超过timeout时间段后还没获取到锁,返回超时错误

func (Mutex) Unlock

func (m Mutex) Unlock() error

Jump to

Keyboard shortcuts

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