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 ¶
- func NewClient(refs claim.ClaimRefClient, now func() libtime.DateTime) claim.ClaimClient
- type Client
- func (c *Client) Acquire(ctx context.Context, target claim.ClaimTarget, holder string, ...) (*claim.Claim, error)
- func (c *Client) List(ctx context.Context, holder string) ([]claim.Claim, error)
- func (c *Client) Read(ctx context.Context, target claim.ClaimTarget) (*claim.Claim, error)
- func (c *Client) Release(ctx context.Context, target claim.ClaimTarget, leaseToken string) error
- func (c *Client) Renew(ctx context.Context, target claim.ClaimTarget, holder string, ...) (*claim.Claim, error)
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) 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.