lock

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Type primitive.Type = "Lock"

Type is the lock type

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetLock gets the Lock instance of the given name
	GetLock(ctx context.Context, name string) (Lock, error)
}

Client provides an API for creating Locks

type IfVersionOption

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

IfVersionOption is a lock option for checking the version

func IfVersion

func IfVersion(version uint64) IfVersionOption

IfVersion sets the lock version to check

type IsLockedOption

type IsLockedOption interface {
	// contains filtered or unexported methods
}

IsLockedOption is an option for IsLocked calls

type Lock

type Lock interface {
	primitive.Primitive

	// Lock acquires the lock
	Lock(ctx context.Context, opts ...LockOption) (uint64, error)

	// Unlock releases the lock
	Unlock(ctx context.Context, opts ...UnlockOption) (bool, error)

	// IsLocked returns a bool indicating whether the lock is held
	IsLocked(ctx context.Context, opts ...IsLockedOption) (bool, error)
}

Lock provides distributed concurrency control

func New

func New(ctx context.Context, name primitive.Name, partitions []*primitive.Session) (Lock, error)

New creates a new Lock primitive for the given partitions The lock will be created in one of the given partitions.

type LockOption

type LockOption interface {
	// contains filtered or unexported methods
}

LockOption is an option for Lock calls

func WithTimeout

func WithTimeout(timeout time.Duration) LockOption

WithTimeout sets the lock timeout

type UnlockOption

type UnlockOption interface {
	// contains filtered or unexported methods
}

UnlockOption is an option for Unlock calls

Jump to

Keyboard shortcuts

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