locker

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

type Locker interface {
	// TryRun attempts to run a non-exclusive Restic job.
	// The given runnable is executed if:
	//   - concurrency limit for the same type of job is not yet reached
	//   - and no other exclusive job is running (batch Job with Active pods > 0)
	//
	// The given runnable runs synchronously within a locked mutex, so it should be as short as possible as it blocks other runnables.
	// It returns false with nil error if the preconditions aren't met, false with an error if preconditions cannot be determined, or true with the error returned by the runnable.
	TryRun(ctx context.Context, config job.Config, concurrencyLimit int, runnable func(ctx context.Context) error) (bool, error)

	// TryRunExclusively attempts to run an exclusive Restic job.
	// The given runnable is executed if there are no other jobs running (batch Job with Active pods == 0).
	//
	// The given runnable runs synchronously within a locked mutex, so it should be as short as possible as it blocks other runnables.
	// It returns false with nil error if the precondition isn't met, false with an error if precondition cannot be determined, or true with the error returned by the runnable.
	TryRunExclusively(ctx context.Context, runnable func(ctx context.Context) error) (bool, error)
}

Locker is used to synchronize different controllers that operate on the same Restic repository.

func GetForRepository

func GetForRepository(clt client.Client, repository string) Locker

GetForRepository returns a Locker scoped for the given repository.

Jump to

Keyboard shortcuts

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