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

modelcatalog

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package modelcatalog persists the model catalogue each provider last reported and seeds a provider registry's in-memory catalogue from that copy.

It exists because the provider package must not import the session store (the dependency runs the other way) and the server is not the only entry point that builds a registry: `ogcode index` and `ogcode run` do too, and each needs its picker populated before its first network fetch. Keeping the conversions and the seed/persist logic here means all three entry points share one implementation rather than three drift-prone copies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Persist

func Persist(database *db.DB, refreshed map[string][]provider.ModelInfo) error

Persist writes each refreshed catalogue back to the database, so the next process start seeds from it. Rows are replaced per provider, so a model the endpoint stopped serving disappears rather than lingering.

func Prune

func Prune(registry *provider.Registry, database *db.DB) error

Prune drops the stored catalogue of every provider the registry does not hold, so a link that was disconnected (or a key that was cleared) does not leave a list that would reappear — stale, from a previous account — the moment the provider is re-added. Call it only with a registry that holds the FULL configured provider set (the server's), never with a partial one.

func Seed

func Seed(registry *provider.Registry, database *db.DB) error

Seed populates every registered provider's in-memory catalogue from the persisted copy, so Models() answers with the last known list immediately on startup instead of waiting for a background fetch. A read failure is returned with the seed left partial — the caller logs it and the providers simply fall back to their compiled-in lists.

Seed only ever ADDS to a provider's catalogue; it never deletes rows. A registry built from a subset of the configured providers (the headless CLI registers only the ones its environment names) must not be able to wipe another entry point's stored catalogue — see Prune for the deliberate removal, which only a registry holding the full provider set may call.

Types

This section is empty.

Jump to

Keyboard shortcuts

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