host

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

store.go is the data-access layer for Host. It maps Host domain structs to and from the sqlc-generated row types. Metadata JSONB encoding is delegated to app/meta; this file only knows about Host's Spec.

Store is concrete — no interface declared here. Consumers (snapshot composer, admin handlers, seed) each declare their own narrow interface locally if they want a test seam.

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"`
}

Host is a single upstream serving endpoint.

func (*Host) IsEnabled

func (h *Host) IsEnabled() bool

IsEnabled returns true when Enabled is unset or explicitly true.

func (*Host) Validate

func (h *Host) Validate() error

Validate runs intra-row rules via the shared meta.Validator and enforces the Host-specific invariant that Owner.Kind, when set, is system. Empty is accepted — Hosts are inherently system-defined infrastructure, so YAML authors are not required to spell that out.

type Spec

type Spec struct {
	// BaseURL is the upstream root. Required.
	BaseURL string `json:"baseURL" yaml:"baseURL" validate:"required,http_url"`

	// 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 `json:"backend,omitempty" yaml:"backend,omitempty"`

	// Policies is the host's menu of upstream tier Policy ids a HostKey can
	// mirror. Every entry must be a Policy with Meta.Owner = {kind:host, id:
	// <this host's id>}. The composition layer enforces the menu invariant.
	Policies []string `json:"policies,omitempty" yaml:"policies,omitempty"`

	// DefaultPolicy is the Policy id from Policies a HostKey inherits when
	// its Spec.PolicyID is empty. Must be one of Policies. Optional — if
	// empty, HostKey.Spec.PolicyID becomes required.
	DefaultPolicy string `json:"defaultPolicy,omitempty" yaml:"defaultPolicy,omitempty"`

	// Enabled defaults to true when nil.
	Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`

	// Display metadata — operator-set, optional.
	HomepageURL   string     `json:"homepageURL,omitempty"   yaml:"homepageURL,omitempty"   validate:"omitempty,http_url"`
	DocsURL       string     `json:"docsURL,omitempty"       yaml:"docsURL,omitempty"       validate:"omitempty,http_url"`
	ConsoleURL    string     `json:"consoleURL,omitempty"    yaml:"consoleURL,omitempty"    validate:"omitempty,http_url"`
	StatusPageURL string     `json:"statusPageURL,omitempty" yaml:"statusPageURL,omitempty" validate:"omitempty,http_url"`
	Icon          *meta.Icon `json:"icon,omitempty"          yaml:"icon,omitempty"`
}

Spec carries the routing + display fields.

type Store

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

Store is the Host data-access type. Holds a sqlc Queries handle.

func NewStore

func NewStore(q *gen.Queries) *Store

NewStore constructs a Store from an existing sqlc Queries handle. The caller owns the pgxpool / transaction; Store performs no connection mgmt.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

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.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*Host, error)

Get returns the Host with the given id, or (nil, nil) if not found.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*Host, error)

List returns every Host row in slug order. Cheap — catalog is small.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, h *Host) error

Upsert writes h. Caller is responsible for stamping Meta.ID.

Jump to

Keyboard shortcuts

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