lock

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.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 GitCredentials

type GitCredentials struct {
	WorkspaceHost string
	Username      string
}

GitCredentials are unique to the user and workspace.

func (GitCredentials) GetLockId

func (g GitCredentials) GetLockId() string

type Lock

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

Lock is a lock that is acquired by a single test. Locks can be acquired by calling the Acquire() method on a LockOptions struct. The lock is released when the Unlock() method is called. Failures to acquire the lock in time, to renew the leease, or to release the lock will cause the test to fail.

func Acquire

func Acquire(ctx context.Context, lockable core.Lockable, os ...LockOption) (*Lock, error)

Acquire acquires a lock according to the provided lock options. If successful, the lock is returned. The caller is responsible for calling the Unlock() method on the returned lock when the lock is no longer needed. If the lock is held at the moment Acquire() is called, the method will block for up to the lease duration, retrying periodically to acquire the lock. If the lock is not acquired in time, an error will be returned.

When the lock is no longer needed, the caller should call the Unlock() method on the returned lock. This will release the lock and return any errors that occurred while releasing the lock. If a *testing.T is provided as a LockOption, the Unlock() method will be called automatically when the test completes.

By default, the lock will be acquired for 1 minute. This can be changed by passing the WithLeaseDuration() LockOption.

By default, the lock will be acquired using a Databricks backend. This can be changed by passing the WithBackend() LockOption.

func (*Lock) Unlock

func (l *Lock) Unlock() error

type LockOption

type LockOption func(*LockOptions)

func InTest

func InTest(t *testing.T) LockOption

func WithBackend

func WithBackend(backend core.LockBackend) LockOption

func WithLeaseDuration

func WithLeaseDuration(duration time.Duration) LockOption

type LockOptions

type LockOptions struct {
	LeaseDuration time.Duration
	Backend       core.LockBackend
	T             *testing.T
}

type LockableImpl

type LockableImpl[R any] struct {
	// contains filtered or unexported fields
}

LockableImpl is a default implementation of Lockable. If r is a struct, it uses reflection to generate a unique lock ID based on the name and fields of the struct. If r is a string, it uses the string as the lock ID.

func NewLockable

func NewLockable[R any](r R) LockableImpl[R]

func (LockableImpl[R]) GetLockId

func (l LockableImpl[R]) GetLockId() string

type Workspace

type Workspace struct {
	WorkspaceId string
}

Some operations require locking the entire workspace.

func (Workspace) GetLockId

func (w Workspace) GetLockId() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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