locker

package
v0.0.0-...-bb92df6 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: OSL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

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

Memory TryLocker for non clustered applications

func NewMemory

func NewMemory() *Memory

NewMemory creates a new memory based lock

func (*Memory) TryLock

func (m *Memory) TryLock(_ context.Context, key string, _ time.Duration) (placeorder.Unlock, error)

TryLock unblocking implementation see https://github.com/LK4D4/trylock/blob/master/trylock.go

type Redis

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

Redis TryLocker for clustered applications

func NewRedis

func NewRedis(
	cfg *struct {
		MaxIdle                 int    `inject:"config:commerce.checkout.placeorder.lock.redis.maxIdle"`
		IdleTimeoutMilliseconds int    `inject:"config:commerce.checkout.placeorder.lock.redis.idleTimeoutMilliseconds"`
		Network                 string `inject:"config:commerce.checkout.placeorder.lock.redis.network"`
		Address                 string `inject:"config:commerce.checkout.placeorder.lock.redis.address"`
		Database                int    `inject:"config:commerce.checkout.placeorder.lock.redis.database"`
	},
) *Redis

NewRedis creates a new distributed mutex using multiple Redis connection pools.

func (*Redis) Status

func (r *Redis) Status() (alive bool, details string)

Status is the health check

func (*Redis) TryLock

func (r *Redis) TryLock(ctx context.Context, key string, maxlockduration time.Duration) (placeorder.Unlock, error)

TryLock ties once to acquire a lock and returns the unlock func if successful

Jump to

Keyboard shortcuts

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