Documentation
¶
Overview ¶
Package host is the domain layer for the Host entity — a serving endpoint the relay forwards requests to. Examples: openai-direct (api.openai.com), bedrock-us-east-1 (AWS Bedrock in that region), azure-prod-eastus (one Azure OpenAI deployment), together, groq, fireworks. Each represents a distinct URL + auth combination.
Hosts are operator-defined infrastructure (Owner.Kind=system). HostKeys belong to Hosts. Which Hosts can serve a Model is declared by standalone HostBinding entities (app/binding), not on the Model.
Storage: not yet wired to PG (needs a new hosts table + sqlc queries). The catalog composition layer consumes a HostLister interface; tests supply in-memory fakes. The real Store will land alongside the schema migration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct {
Meta meta.Metadata `json:"metadata" yaml:"metadata"`
Spec Spec `json:"spec" yaml:"spec"`
// Status is runtime-observed health, overlaid by the control-API enrich
// step from the host-health store. nil when no observation exists yet
// (no traffic since boot, or the record TTL'd out) — the UI shows
// "unknown". Never persisted and never loaded from YAML.
Status *Status `` /* 153-byte string literal not displayed */
}
Host is a single upstream serving endpoint.
Spec is desired state (operator-managed, persisted in PG). Status is observed runtime state (data-plane-managed, NOT persisted — overlaid from kv at read time, like HostKey.Policies). The split mirrors the k8s spec/status convention.
func (*Host) Validate ¶
Validate runs intra-row rules via the shared meta.Validator and enforces the Host owner rule: a Host is shared catalog data owned by the deployment (system, or empty), never by a user, team or project. A host names an endpoint the relay itself dials, so who may write one is decided by roles alone.
type HostHealth ¶ added in v0.2.0
type HostHealth string
HostHealth is the observed reachability of a host's upstream.
const ( // HealthUnknown — no observation yet (no traffic since boot or the record // TTL'd out). The zero value. HealthUnknown HostHealth = "" // HealthHealthy — the upstream was reached on the most recent request // (any HTTP response, even 4xx/5xx — reachability, not success). HealthHealthy HostHealth = "healthy" // HealthUnreachable — the most recent request failed to establish a // connection (dial refused / DNS / TLS) after the pipeline's retries. HealthUnreachable HostHealth = "unreachable" )
type Spec ¶
type Spec struct {
// BaseURL is the upstream root. Empty is valid but leaves the host
// unroutable — a catalog may ship a self-hosted host for the operator to
// point at their own endpoint after install.
BaseURL string `` /* 144-byte string literal not displayed */
// Path overrides the adapter's shape-default upstream path (Spec.DefaultPath)
// when this host's endpoint doesn't follow the vendor-canonical layout.
// Used verbatim when set — an explicit "" means BaseURL is the complete
// endpoint URL and nothing is appended. Unset (nil) keeps the shape default.
Path *string `` /* 188-byte string literal not displayed */
// Backend is the free-form bag of backend-specific config (Bedrock region,
// Azure deployment, Vertex project/location, etc.). Each provider client
// reads the keys it needs and ignores the rest. Optional.
Backend map[string]string `` /* 157-byte string literal not displayed */
// PricingStrategies is the menu of billing modes this upstream offers:
// "api" (per-token metered) and/or "sub" (flat-rate subscription). A
// HostKey's Spec.PricingStrategy must be one of these. Empty defaults to
// ["api"]. Anthropic offers both (an API key or a Max subscription reach
// the same endpoint); Ollama Cloud is ["sub"] only; most hosts are
// ["api"]. Catalog-declared; the operator picks one per HostKey.
PricingStrategies []string `` /* 262-byte string literal not displayed */
// NoAuth marks an upstream that needs no API key (a self-hosted Ollama on
// the operator's network). When set, routing injects a synthetic anonymous
// key for this host instead of requiring a real HostKey, and the adapter
// sends no Authorization header. Operator-managed (per-deployment), not a
// catalog-fixed property — Ollama Cloud still needs a key.
NoAuth bool `` /* 196-byte string literal not displayed */
// Enabled defaults to true when nil.
Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty" doc:"False stops routing to the host. Omitted means true."`
// Display metadata — operator-set, optional.
HomepageURL string `json:"homepageURL,omitempty" yaml:"homepageURL,omitempty" validate:"omitempty,http_url" doc:"Host homepage."`
DocsURL string `json:"docsURL,omitempty" yaml:"docsURL,omitempty" validate:"omitempty,http_url" doc:"Host API documentation."`
ConsoleURL string `` /* 134-byte string literal not displayed */
StatusPageURL string `json:"statusPageURL,omitempty" yaml:"statusPageURL,omitempty" validate:"omitempty,http_url" doc:"Host status page."`
Icon *meta.Icon `json:"icon,omitempty" yaml:"icon,omitempty" doc:"Icon shown for the host."`
}
Spec carries the routing + display fields.
func (Spec) AllowsStrategy ¶ added in v0.3.0
AllowsStrategy reports whether a HostKey may declare the given pricing strategy on this host. This is the composition-layer membership invariant for HostKey.Spec.PricingStrategy.
func (Spec) Strategies ¶ added in v0.3.0
Strategies returns the host's offered billing modes, defaulting an empty menu to ["api"].
type Status ¶ added in v0.2.0
type Status struct {
Health HostHealth `json:"health" enum:"healthy,unreachable" doc:"healthy after a successful dial, unreachable after dial failures."`
LastError string `json:"lastError,omitempty" doc:"Last dial-failure error excerpt; set while unreachable."`
ConsecutiveFailures int `json:"consecutiveFailures,omitempty" doc:"Consecutive dial failures; 0 when healthy."`
LastTransition time.Time `json:"lastTransition,omitempty" doc:"When health was last recorded."`
LastSuccess time.Time `json:"lastSuccess,omitempty" doc:"When the host was last reachable."`
}
Status is runtime-observed health for a Host. Written by the data plane on each request outcome, read by the admin API. Not persisted.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the Host data-access type. Holds a sqlc Queries handle.
func NewStore ¶
NewStore constructs a Store from an existing sqlc Queries handle. The caller owns the pgxpool / transaction; Store performs no connection mgmt.
func (*Store) Delete ¶
Delete removes a Host by id. sqlc returns nil on a no-rows delete; callers can pre-check existence via the snapshot if they need a 404.