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

usage

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("usage unavailable")

Functions

This section is empty.

Types

type Cache

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

Cache bounds quota history to 64 account keys and coalesces concurrent reads. Keys are caller-owned account identities or credential digests, never raw credentials.

func (*Cache) Clear

func (c *Cache) Clear()

func (*Cache) Fetch

func (c *Cache) Fetch(ctx context.Context, key string, fetch func(context.Context) (Snapshot, error)) (Snapshot, error)

func (*Cache) Peek

func (c *Cache) Peek(key string) (Snapshot, bool)

type Client

type Client struct {
	Cache                   *Cache
	HTTPClient              *http.Client
	CodexURL, OpenCodeGoURL string
}

Client reads provider-reported quota only. URLs are injectable for tests and private deployments; credentials never follow redirects.

func (Client) Fetch

func (c Client) Fetch(ctx context.Context, provider string, credential auth.ModelAuth) (Snapshot, error)

type Snapshot

type Snapshot struct {
	Plan      string    `json:"plan,omitempty"`
	Windows   []Window  `json:"windows"`
	CheckedAt time.Time `json:"checked_at,omitzero"`
}

func (Snapshot) Summary

func (u Snapshot) Summary() string

type Window

type Window struct {
	Name      string    `json:"name"`
	Remaining float64   `json:"remaining"` // percent
	ResetsAt  time.Time `json:"resets_at,omitzero"`
}

Window and Snapshot are also Bridge wire: an instance describes its provider's limits with them.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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