locking

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

locking

Limits asynchronous processing of single Backup/Restore task, aggregated by RequestedBackupAction or ScheduledBackup.

Background:

There are multiple controllers running in parallel. Locking mechanism is making sure that single RequestedBackupAction or ScheduledBackup is processed only by one controller at a time.

Asynchronous processing:

Still all controllers are asynchronous - multiple RequestedBackupAction or ScheduledBackup of different .metadata.name are processed in parallel.

Reason:

Avoid loop - one controller is updating .status field of our CRD, another one receives an update and starts processing, but the first controller still not finished processing, and then triggers a next .status update, and other controller is picking an update event... that's crazy! That's why we limit the parallelism, to make it simpler.

Documentation

Index

Constants

View Source
const (
	ErrAlreadyLocked = "Already locked"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryLocker

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

func NewInMemoryLocker

func NewInMemoryLocker() *InMemoryLocker

func (*InMemoryLocker) Close

func (iml *InMemoryLocker) Close()

func (*InMemoryLocker) Done

func (iml *InMemoryLocker) Done(ctx context.Context, session LockSession)

func (*InMemoryLocker) Obtain

func (iml *InMemoryLocker) Obtain(ctx context.Context, req ctrl.Request) LockSession

type LockSession

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

func (*LockSession) AlreadyLocked

func (ls *LockSession) AlreadyLocked() bool

func (*LockSession) GetError

func (ls *LockSession) GetError() error

func (*LockSession) HasFailure

func (ls *LockSession) HasFailure() bool

type Locker

type Locker interface {
	Obtain(ctx context.Context, req ctrl.Request) LockSession
	Done(ctx context.Context, session LockSession)
	Close()
}

type RedisDistributedLocker

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

func NewRedisDistributedLocker

func NewRedisDistributedLocker(proto string, host string, port int) *RedisDistributedLocker

func (*RedisDistributedLocker) Close

func (rdl *RedisDistributedLocker) Close()

func (*RedisDistributedLocker) Done

func (rdl *RedisDistributedLocker) Done(ctx context.Context, session LockSession)

func (*RedisDistributedLocker) Obtain

Jump to

Keyboard shortcuts

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