dlock

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 5 Imported by: 0

README

dlock

该目录只是对外公开的便捷转发层。

  • 面向业务代码提供 gorp/dlock 入口
  • 真实实现仍在 framework/*contrib/*
  • 不在这里承载独立分布式锁实现或新语义

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

Get returns the distributed lock service from the container. Get 从容器获取分布式锁服务。

func GetOrPanic

GetOrPanic returns the distributed lock service from the container and panics on failure. GetOrPanic 从容器获取分布式锁服务,失败 panic。

func Lock

Lock acquires a lock using the distributed lock service from the container. Lock 使用容器中的分布式锁获取锁。

func TryLock

func TryLock(ctx context.Context, c runtimecontract.Container, key string, ttl time.Duration) (bool, error)

TryLock tries to acquire a lock using the distributed lock service from the container. TryLock 使用容器中的分布式锁尝试获取锁。

func Unlock

Unlock releases a lock using the distributed lock service from the container. Unlock 使用容器中的分布式锁释放锁。

func WithLock

func WithLock(ctx context.Context, c runtimecontract.Container, key string, ttl time.Duration, fn func() error) error

WithLock executes a function while holding a distributed lock. WithLock 使用容器中的分布式锁包裹执行函数。

Example:

err := dlock.WithLock(ctx, c, "order:42", 5*time.Second, func() error {
    return processOrder(ctx, 42)
})

Types

type DistributedLock

type DistributedLock = datacontract.DistributedLock

DistributedLock is the top-level alias of the distributed lock contract. DistributedLock 是分布式锁契约的顶层别名。

type DistributedLockConfig

type DistributedLockConfig = datacontract.DistributedLockConfig

DistributedLockConfig is the top-level alias of the distributed lock config contract. DistributedLockConfig 是分布式锁配置契约的顶层别名。

Jump to

Keyboard shortcuts

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