Documentation
¶
Overview ¶
Package modelinventory defines the backend-owned model inventory contract.
Index ¶
Constants ¶
const ( ErrorCodeNone = "" ErrorCodeTimeout = "timeout" ErrorCodeCanceled = "canceled" ErrorCodeEmpty = "empty" ErrorCodeInvalidInventory = "invalid_inventory" )
Stable machine-readable inventory error codes. Never carry raw provider error text.
Variables ¶
var ErrNilContext = errors.New("modelinventory: nil context")
Functions ¶
func IsOperational ¶
IsOperational reports whether err is an operational (fail-soft) inventory failure.
Types ¶
type AcceptedInventory ¶
type AcceptedInventory interface {
AcceptInventory(models []Model)
}
AcceptedInventory is optionally implemented by Provider values that maintain a local allowlist aligned with inventory accepted into the aggregate registry. Core calls AcceptInventory after publishing a registry snapshot: accepted backends receive their published models, and omitted backends receive a nil or empty slice (both must clear). An empty/nil slice must clear the allowlist.
type Discovery ¶
type Discovery struct {
Status DiscoveryStatus
Source Source
ModelCount int
ErrorCode string
}
Discovery is protocol-neutral per-inventory discovery metadata.
func DiscoveryFromLoadError ¶
DiscoveryFromLoadError builds discovery metadata for a LoadModels failure. Raw error text is not copied; only a stable ErrorCode is retained.
func DiscoveryFromSnapshot ¶
DiscoveryFromSnapshot builds discovery metadata for a successful LoadModels snapshot.
type DiscoveryStatus ¶
type DiscoveryStatus string
DiscoveryStatus is protocol-neutral inventory discovery outcome for one backend instance.
const ( DiscoveryStatusOK DiscoveryStatus = "ok" DiscoveryStatusEmpty DiscoveryStatus = "empty" DiscoveryStatusCached DiscoveryStatus = "cached" )
type ErrorProvider ¶
type ErrorProvider struct {
Err error
}
func (ErrorProvider) LoadModels ¶
func (p ErrorProvider) LoadModels(ctx context.Context) (Snapshot, error)
func (ErrorProvider) StaticInventory ¶
func (p ErrorProvider) StaticInventory() bool
StaticInventory marks ErrorProvider as non-refreshable so a cached snapshot loaded at startup is not repeatedly overwritten by the same construction error.
type OperationalError ¶
OperationalError marks a fail-soft inventory load failure. Aggregators omit the backend without aborting unrelated successful inventories.
func (*OperationalError) Error ¶
func (e *OperationalError) Error() string
func (*OperationalError) Operational ¶
func (e *OperationalError) Operational() bool
Operational reports that this error is safe to fail soft during inventory aggregation.
func (*OperationalError) Unwrap ¶
func (e *OperationalError) Unwrap() error
type StaticInventory ¶
type StaticInventory interface {
StaticInventory() bool
}
StaticInventory marks providers whose inventory is local and does not require periodic remote refresh.
type StaticProvider ¶
StaticProvider returns a fixed inventory snapshot. Models and Warnings slices are treated as immutable after construction; LoadModels returns them without cloning. Callers must not mutate the returned Snapshot slices.
func (StaticProvider) LoadModels ¶
func (p StaticProvider) LoadModels(ctx context.Context) (Snapshot, error)
func (StaticProvider) StaticInventory ¶
func (p StaticProvider) StaticInventory() bool