Documentation
¶
Overview ¶
Package catalog fetches and caches the api2convert conversions catalog (the supported categories, targets and their option schemas), so discovery and completion are fast and tolerant of transient offline moments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog struct {
FetchedAt time.Time `json:"fetched_at"`
Conversions []Conversion `json:"conversions"`
}
Catalog is the cached set of supported conversions.
func Load ¶
func Load(ctx context.Context, c *api2convert.Client, refresh bool, cacheKey string) (*Catalog, error)
Load returns the catalog, using a fresh cached copy when available (unless refresh is set). On a fetch error it falls back to any cached copy, even stale. cacheKey scopes the on-disk cache to an account (e.g. apiKey+"|"+baseURL).
func (*Catalog) Categories ¶
Categories returns the sorted, unique category names.
func (*Catalog) Filter ¶
func (c *Catalog) Filter(category string) []Conversion
Filter returns conversions in a category (empty = all), sorted by target.
func (*Catalog) Search ¶
func (c *Catalog) Search(q string) []Conversion
Search returns conversions whose target or category contains q (case-insensitive).