Help us shape the future of Go! Take the 2026 Go Developer Survey

core

package
v0.190.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockBackend

type LockBackend interface {
	// PrepareBackend prepares the backend for use. This is called once per lock.
	// Locking is aborted if this fails.
	PrepareBackend(ctx context.Context, lockId string) error

	// AcquireLock acquires the lock. This is called once per lock. Locking is aborted
	// if this fails.
	AcquireLock(ctx context.Context, contents *LockState) error

	// RenewLock renews the lock. This is called periodically while the lock is held.
	RenewLock(ctx context.Context, leaseId string) error

	// ReleaseLock releases the lock. This is called once per lock.
	ReleaseLock(ctx context.Context, leaseId string) error

	// RefreshDuration returns the duration between calls to RenewLock.
	RefreshDuration() time.Duration
}

LockBackend is the interface for a lock backend.

type LockState

type LockState struct {
	// Lockable is the lock id of the lockable resource.
	Lockable string

	// LeaseId is the lease id of the lock.
	LeaseId string

	// Start is the time the lock was acquired.
	Start time.Time

	// Expiry is the time the lock expires.
	Expiry time.Time

	// IsInDebug is true if the test is running in debug mode.
	IsInDebug bool

	// Test is the name of the test, if applicable.
	Test string

	// User is the user running the test.
	User string `env:"USER"`

	// GithubActions is true if the test is running in Github Actions.
	GithubActions string `env:"GITHUB_ACTIONS"`

	// GithubRef is the ref of the Github Actions workflow.
	GithubRef string `env:"GITHUB_REF"`

	// GithubRepository is the repository of the Github Actions workflow, e.g. `databricks/databricks-sdk-go`.
	GithubRepository string `env:"GITHUB_REPOSITORY"`

	// GithubRunId is the ID of the Github Actions run.
	GithubRunId string `env:"GITHUB_RUN_ID"`

	// GithubRunNumber is the number of the Github Actions run.
	GithubRunNumber string `env:"GITHUB_RUN_NUMBER"`

	// GithubSha is the SHA of the Github Actions commit.
	GithubSha string `env:"GITHUB_SHA"`

	// GithubWorkflow is the name of the Github Actions workflow.
	GithubWorkflow string `env:"GITHUB_WORKFLOW"`
}

LockState represents the state of a lock.

func NewLockState

func NewLockState(lockable Lockable, leaseId string, leaseDuration time.Duration, t *testing.T) *LockState

NewLockState creates a new LockState object with the given lockable, lease ID, and lease duration. If t is not nil, the test name is also set.

func (*LockState) Extend

func (l *LockState) Extend(duration time.Duration)

Extend() resets the lock's expiry to the current time plus the given duration. This method only updates the state object; it does not actually persist the change to the lock backend.

func (*LockState) IsValid

func (l *LockState) IsValid() bool

IsValid() returns true if the lock has not yet expired.

type Lockable

type Lockable interface {
	// GetLockId returns the lock id for the resource.
	GetLockId() string
}

Lockable is the interface for a lockable resource.

Jump to

Keyboard shortcuts

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