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

claimtest

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package claimtest provides test doubles for the claim package's typed client.

It exists so a test that already owns a compare-and-swap ref store can drive the lease manager without standing up an HTTP server: the adapter applies the same rules vault-api applies — a live claim refuses an acquire, an expired one is taken over, a stale token is a lost lease — over whatever ClaimRefClient the test supplies. The HTTP-level contract itself is covered separately by vault_api_client_test.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(refs claim.ClaimRefClient, now func() libtime.DateTime) claim.ClaimClient

NewClient returns a ClaimClient over refs. now supplies the clock a lease is computed against, so a test can move time without touching the store.

Types

type Client

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

Client adapts a ClaimRefClient store to the typed ClaimClient.

func (*Client) Acquire

func (c *Client) Acquire(
	ctx context.Context,
	target claim.ClaimTarget,
	holder string,
	claimantTaskID string,
	ttlSeconds int,
) (*claim.Claim, error)

Acquire takes the claim for holder, taking over an expired lease.

func (*Client) List

func (c *Client) List(ctx context.Context, holder string) ([]claim.Claim, error)

List returns every claim, optionally narrowed to one holder.

func (*Client) Read

func (c *Client) Read(ctx context.Context, target claim.ClaimTarget) (*claim.Claim, error)

Read returns the current claim, or ErrClaimFree when there is none.

func (*Client) Release

func (c *Client) Release(
	ctx context.Context,
	target claim.ClaimTarget,
	leaseToken string,
) error

Release drops the claim the token names.

func (*Client) Renew

func (c *Client) Renew(
	ctx context.Context,
	target claim.ClaimTarget,
	holder string,
	leaseToken string,
	claimantTaskID string,
	ttlSeconds int,
) (*claim.Claim, error)

Renew extends the lease the token names. A token that is not current is a lost lease, never a silent success.

Jump to

Keyboard shortcuts

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