lease

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

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = boskos.ErrNotFound

Functions

This section is empty.

Types

type Client

type Client interface {
	// Acquire leases `n` resources and returns the lease names.
	// Will block until resources are available or 150m pass, `n` must be > 0.
	// `ctx` can be used to abort the operation, `cancel` is called if any
	// subsequent updates to the lease fail.
	Acquire(rtype string, n uint, ctx context.Context, cancel context.CancelFunc) ([]string, error)
	//AcquireIfAvailableImmediately leases `n` resources and returns the lease names.
	// Does not block, and only leases the resources if they are available right away.
	AcquireIfAvailableImmediately(rtype string, n uint, cancel context.CancelFunc) ([]string, error)
	// Heartbeat updates all leases. It calls the cancellation function of each
	// lease it fails to update.
	Heartbeat() error
	// Release ends one lease by name.
	Release(name string) error
	// ReleaseAll ends all leases and returns the names of those that were
	// successfully released.
	ReleaseAll() ([]string, error)
	// Metrics queries the states of a particular resource, for informational
	// purposes.
	Metrics(rtype string) (Metrics, error)
}

Client manages resource leases, acquiring, releasing, and keeping them updated.

func NewClient

func NewClient(owner, url, username string, passwordGetter func() []byte, retries int, acquireTimeout time.Duration) (Client, error)

NewClient creates a client that leases resources with the specified owner.

func NewFakeClient

func NewFakeClient(owner, url string, retries int, failures map[string]error, calls *[]string) Client

type Metrics

type Metrics struct {
	Free, Leased int
}

Jump to

Keyboard shortcuts

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