receipt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0, MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PollInterval = time.Second
	PollRetries  = 10
)
View Source
var ErrNotFound = errors.New("receipt not found")

Functions

This section is empty.

Types

type Client

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

func New

func New(endpoint *url.URL, options ...Option) *Client

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, task ucan.Link) (receipt.AnyReceipt, error)

Fetch a receipt from the receipt API. Returns ErrNotFound if the API responds with http.StatusNotFound.

func (*Client) Poll

func (c *Client) Poll(ctx context.Context, task ucan.Link, options ...PollOption) (receipt.AnyReceipt, error)

Poll attempts to fetch a receipt from the endpoint until a non-404 response is encountered or until the configured maximum retries are made.

type Option

type Option func(c *Client)

func WithCodec

func WithCodec(codec transport.ResponseDecoder) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

type PollOption

type PollOption func(opt *pollConfig)

func WithInterval

func WithInterval(interval time.Duration) PollOption

WithInterval configures the time to wait between poll requests. The default is PollInterval.

func WithRetries

func WithRetries(n int) PollOption

WithRetries configures the maximum number of times that Poll will attempt to fetch a receipt. The default is PollRetries requests. Set it to -1 to poll until a non-404 response is encountered.

Jump to

Keyboard shortcuts

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