receipt

package
v0.0.0-...-e3ecdb0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0, MIT Imports: 14 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func NewHandler

func NewHandler(tokens Finder) http.Handler

NewHandler creates a new http.Handler that serves receipt containers. It expects the URL path to end with the task CID, e.g. /receipt/<task-cid>

Types

type Client

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

func NewClient

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

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, task cid.Cid) (ucan.Receipt, ucan.Container, 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 cid.Cid, options ...PollOption) (ucan.Receipt, ucan.Container, 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 Finder

type Finder interface {
	// FindByTask returns all UCAN containers that have tokens related to the
	// given task i.e. invocations or receipts for the task.
	FindByTask(ctx context.Context, task cid.Cid) iter.Seq2[ucan.Container, error]
}

type Option

type Option func(c *Client)

func WithCodec

func WithCodec(codec ResponseDecoder[*http.Response]) 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.

type ResponseDecoder

type ResponseDecoder[Res any] interface {
	Decode(Res) (ucan.Container, error)
}

Jump to

Keyboard shortcuts

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