lock

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 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, opts ...primitive.Option) (Lock, error)
}

Client provides an API for creating Locks

type GetOption

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

GetOption is an option for IsLocked calls

type Lock

type Lock interface {
	primitive.Primitive

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

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

	// Get gets the lock status
	Get(ctx context.Context, opts ...GetOption) (Status, error)
}

Lock provides distributed concurrency control

func New

func New(ctx context.Context, name string, conn *grpc.ClientConn, opts ...primitive.Option) (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 MatchOption

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

MatchOption is a lock option for checking the version

func IfMatch

func IfMatch(object meta.Object) MatchOption

IfMatch sets the lock version to check

type Option

type Option interface {
	primitive.Option
	// contains filtered or unexported methods
}

Option is a lock option

type State

type State int

State is a lock state

const (
	// StateLocked is the State in which the lock is locked
	StateLocked State = iota
	// StateUnlocked is the State in which the lock is not locked
	StateUnlocked
)

type Status

type Status struct {
	meta.ObjectMeta
	State State
}

Status is the lock status

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