catalogstore

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 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 catalogstore is the Postgres data-access layer for the catalog kinds (provider, host, model, pricing, binding, policy, ratelimit). The kinds' types and validation live in pkg/catalogkind, free of storage, so tools that read the catalog without a database share them. Each store is concrete, with no interface declared here; consumers declare their own narrow interface if they want a test seam. Other entities keep their stores beside their types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BindingStore

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

BindingStore is the HostBinding data-access type.

func NewBindingStore

func NewBindingStore(db gen.DBTX) *BindingStore

NewBindingStore constructs a BindingStore bound to a pool or an open transaction.

func (*BindingStore) Delete

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

Delete removes a HostBinding by id.

func (*BindingStore) DeleteAtVersion added in v0.21.0

func (s *BindingStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the HostBinding while it still has version.

func (*BindingStore) Get

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

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

func (*BindingStore) List

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

List returns every HostBinding row.

func (*BindingStore) Upsert

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

Upsert writes b. Caller stamps Meta.ID.

type DetachedStore added in v0.21.0

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

DetachedStore answers whether any catalog row is detached, in one query cheap enough to ask on every catalog poll.

func NewDetachedStore added in v0.21.0

func NewDetachedStore(q *gen.Queries) *DetachedStore

NewDetachedStore constructs a DetachedStore from an existing sqlc Queries handle.

func (*DetachedStore) Any added in v0.21.0

func (s *DetachedStore) Any(ctx context.Context) (bool, error)

Any reports whether a row of a catalog kind carries CatalogDetachedAt.

type HostStore

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

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

func NewHostStore

func NewHostStore(q *gen.Queries) *HostStore

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

func (*HostStore) Delete

func (s *HostStore) 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 (*HostStore) DeleteAtVersion added in v0.21.0

func (s *HostStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the Host while it still has version.

func (*HostStore) Get

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

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

func (*HostStore) List

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

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

func (*HostStore) Upsert

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

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

type ModelStore

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

ModelStore is the Model data-access type.

func NewModelStore

func NewModelStore(q *gen.Queries) *ModelStore

NewModelStore constructs a ModelStore from an existing sqlc Queries handle.

func (*ModelStore) Delete

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

Delete removes a Model by id.

func (*ModelStore) DeleteAtVersion added in v0.21.0

func (s *ModelStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the Model while it still has version.

func (*ModelStore) Get

func (s *ModelStore) Get(ctx context.Context, id string) (*model.Model, error)

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

func (*ModelStore) List

func (s *ModelStore) List(ctx context.Context) ([]*model.Model, error)

List returns every Model row.

func (*ModelStore) Upsert

func (s *ModelStore) Upsert(ctx context.Context, m *model.Model) error

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

type PolicyStore

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

PolicyStore is the Policy data-access type. Holds a DB rather than Queries so Upsert can run a multi-table transaction; List reads without one.

func NewPolicyStore

func NewPolicyStore(db storage.DB) *PolicyStore

NewPolicyStore constructs a PolicyStore bound to a pool or an open transaction.

func (*PolicyStore) Delete

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

Delete removes a Policy by id. Junction rows cascade via FK.

func (*PolicyStore) DeleteAtVersion added in v0.21.0

func (s *PolicyStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the Policy while it still has version.

func (*PolicyStore) Get

func (s *PolicyStore) Get(ctx context.Context, id string) (*policy.Policy, error)

Get returns the Policy with the given id and its links, or (nil, nil) if not found.

func (*PolicyStore) List

func (s *PolicyStore) List(ctx context.Context) ([]*policy.Policy, error)

List returns every Policy row with its links.

func (*PolicyStore) Upsert

func (s *PolicyStore) Upsert(ctx context.Context, p *policy.Policy) error

Upsert writes p across policies + junction tables in a single tx.

type PricingStore

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

PricingStore is the Pricing data-access type. Holds a DB rather than Queries so Upsert can run a multi-table transaction.

func NewPricingStore

func NewPricingStore(db storage.DB) *PricingStore

NewPricingStore constructs a PricingStore bound to a pool or an open transaction.

func (*PricingStore) Delete

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

Delete removes a Pricing by id. Junction rows cascade via FK.

func (*PricingStore) DeleteAtVersion added in v0.21.0

func (s *PricingStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the Pricing while it still has version.

func (*PricingStore) Get

func (s *PricingStore) Get(ctx context.Context, id string) (*pricing.Pricing, error)

Get returns the Pricing with the given id, hydrating TargetModelIDs. Returns (nil, nil) if not found.

func (*PricingStore) List

func (s *PricingStore) List(ctx context.Context) ([]*pricing.Pricing, error)

List returns every Pricing row with Spec.TargetModelIDs hydrated from the pricing_models junction in declaration order.

func (*PricingStore) Upsert

func (s *PricingStore) Upsert(ctx context.Context, p *pricing.Pricing) error

Upsert writes p across pricings + pricing_models in a single tx. Caller stamps Meta.ID and Owner.ID (host id).

type ProviderStore

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

ProviderStore is the Provider data-access type. Holds a sqlc Queries handle.

func NewProviderStore

func NewProviderStore(q *gen.Queries) *ProviderStore

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

func (*ProviderStore) Delete

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

Delete removes a Provider by id. sqlc returns nil on a no-rows delete; callers can pre-check existence via the snapshot if they need a 404.

func (*ProviderStore) DeleteAtVersion added in v0.21.0

func (s *ProviderStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the Provider while it still has version.

func (*ProviderStore) Get

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

func (*ProviderStore) List

func (s *ProviderStore) List(ctx context.Context) ([]*provider.Provider, error)

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

func (*ProviderStore) Upsert

func (s *ProviderStore) Upsert(ctx context.Context, p *provider.Provider) error

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

type RateLimitStore

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

RateLimitStore is the RateLimit data-access type.

func NewRateLimitStore

func NewRateLimitStore(q *gen.Queries) *RateLimitStore

NewRateLimitStore constructs a RateLimitStore from an existing sqlc Queries handle.

func (*RateLimitStore) Delete

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

Delete removes a RateLimit by id.

func (*RateLimitStore) DeleteAtVersion added in v0.21.0

func (s *RateLimitStore) DeleteAtVersion(ctx context.Context, id, version string) error

DeleteAtVersion removes the RateLimit while it still has version.

func (*RateLimitStore) Get

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

func (*RateLimitStore) List

List returns every RateLimit row.

func (*RateLimitStore) Upsert

func (s *RateLimitStore) Upsert(ctx context.Context, rl *ratelimit.RateLimit) error

Upsert writes rl. 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