redis

package
v0.0.0-...-8aeb8a1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock is a Redis lock

func (*Lock) Extend

func (l *Lock) Extend() (bool, error)

Extend extends the lock expiration

func (*Lock) TryLock

func (l *Lock) TryLock(timeout time.Duration) (bool, error)

TryLock Attempts to acquire lock within given amount of time. If lock is not free by that time, returns false. Otherwise, returns true

func (*Lock) Unlock

func (l *Lock) Unlock()

Unlock tries to unlock with defaultUnlockRetries attempts

type LockController

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

LockController is for extend the lock every heartbeat period it allows kill the server and don't wait releasing the lock a long time

func NewController

func NewController(lockName string, heartbeatPeriod time.Duration, lockExtender LockExtender) *LockController

func (*LockController) Close

func (c *LockController) Close()

func (*LockController) StartHeartbeat

func (c *LockController) StartHeartbeat()

StartHeartbeat starts a goroutine for extending the lock

type LockExtender

type LockExtender interface {
	Extend() (bool, error)
}

type LockFactory

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

LockFactory is a Redis based LockFactory

func NewLockFactory

func NewLockFactory(ctx context.Context, pool *meta.RedisPool) (*LockFactory, io.Closer)

NewLockFactory returns configured Redis based LockFactory

func (*LockFactory) CreateLock

func (lf *LockFactory) CreateLock(name string) locks.Lock

CreateLock returns lock instance (not yet locked)

type LocksCloser

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

LocksCloser is designer for graceful closing all locks on server shutdown

func NewLocksCloser

func NewLocksCloser() *LocksCloser

func (*LocksCloser) Add

func (lc *LocksCloser) Add(identifier string, lock locks.Lock)

func (*LocksCloser) Close

func (lc *LocksCloser) Close() error

func (*LocksCloser) Remove

func (lc *LocksCloser) Remove(identifier string)

Jump to

Keyboard shortcuts

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