binding

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 9 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 binding is the domain layer for the HostBinding entity — the first-class join that declares "Model M is served by Host H, via wire adapter A, under upstream name U, priced by Pricing P."

Bindings used to live embedded in model.Spec.Hosts[]. Promoting them to their own entity gives pricing and routing a real row to reference (the embedded array was unaddressable), and lets one Model be bound by many Hosts — including aggregators re-serving another provider's model — without coupling the binding to who owns the Model.

Identity: a binding is a join, owned by no single side, so Owner is system-kind. The (ModelID, HostID) pair is unique — enforced at the DB (UNIQUE constraint) and re-checked in the catalog composition layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Meta meta.Metadata `json:"metadata" yaml:"metadata"`
	Spec Spec          `json:"spec"     yaml:"spec"`
}

Binding declares how one Host serves one Model.

func (*Binding) IsEnabled

func (b *Binding) IsEnabled() bool

IsEnabled returns true when Enabled is unset or explicitly true.

func (*Binding) Serves

func (b *Binding) Serves(snapshotName string) bool

Serves reports whether this binding is eligible to route requests for the given snapshot name. Empty Snapshots means "all"; otherwise membership.

func (*Binding) Validate

func (b *Binding) Validate() error

Validate runs intra-row rules via the shared meta.Validator and enforces the binding-specific invariants:

  • Adapter defaults to OpenAI when omitted, then must be a valid upstream binding (the dispatch key — see adapters.UpstreamBindingNames).

Cross-entity checks (ModelID/HostID/PricingID resolve; the (model, host) pair is unique; Snapshots name real model snapshots) live in the catalog composition + catalogvalidate layers.

type Spec

type Spec struct {
	ModelID      string        `json:"modelId"                yaml:"modelId"                validate:"required,uuid"`
	HostID       string        `json:"hostId"                 yaml:"hostId"                 validate:"required,uuid"`
	Adapter      adapters.Name `json:"adapter"                yaml:"adapter"`
	UpstreamName string        `json:"upstreamName,omitempty" yaml:"upstreamName,omitempty"`
	PricingID    string        `json:"pricingId,omitempty"    yaml:"pricingId,omitempty"    validate:"omitempty,uuid"`
	Enabled      *bool         `json:"enabled,omitempty"      yaml:"enabled,omitempty"`
	// Snapshots optionally narrows which of the Model's snapshots this Host
	// serves. Empty/nil means "all snapshots"; a non-empty list filters
	// routing to those names only.
	Snapshots []string `json:"snapshots,omitempty" yaml:"snapshots,omitempty"`
}

Spec carries the (model, host) join plus the per-host serving terms: the wire adapter, the upstream model name, an optional Pricing ref, and an optional snapshot subset. Cross-refs are stored as ids (the manifest layer resolves names↔ids); PricingID is optional.

type Store

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

Store is the HostBinding data-access type.

func NewStore

func NewStore(db gen.DBTX) *Store

NewStore constructs a Store bound to a pool or an open transaction.

func (*Store) Delete

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

Delete removes a HostBinding by id.

func (*Store) Get

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

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

func (*Store) List

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

List returns every HostBinding row.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, b *Binding) error

Upsert writes b. Caller stamps Meta.ID.

Jump to

Keyboard shortcuts

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