catalogapi

package
v1.118.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package catalogapi serves the /api/v1/admin/api-catalogs surface: the OpenAPI spec bundles that api-kind connections reference by catalog_id, and the per-spec embedding job visibility and retry endpoints. It is a decomposition seam of pkg/admin (which sat at the package size budget); the parent registers it on the admin mux and injects the request-scoped helpers it shares with the other admin routes.

Catalogs are global — one set of specs may back many connections — so every mutation fans out to the live api-gateway toolkits via ReloadConnectionsByCatalog, and to peer replicas via the reloader, so that model-facing surfaces (api_list_endpoints, api_get_endpoint_schema) reflect new content without a restart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mux *http.ServeMux, cfg Config)

Register mounts the API-catalog routes on mux. Reads need only the store; writes additionally need database config mode, matching the gating the parent applies to its other configuration surfaces.

Types

type CatalogReloader

type CatalogReloader interface {
	PublishCatalogReload(catalogID string)
}

CatalogReloader fans a catalog mutation out to peer replicas so their live api-gateway toolkits pick up the new content. Implemented by *platform.Platform; nil on single-replica and test setups, where the local reload below is the whole story.

type CatalogStore

type CatalogStore interface {
	CreateCatalog(ctx context.Context, c apicatalog.Catalog) error
	GetCatalog(ctx context.Context, id string) (*apicatalog.Catalog, error)
	ListCatalogs(ctx context.Context) ([]apicatalog.Catalog, error)
	UpdateCatalog(ctx context.Context, id string, u apicatalog.Update) error
	DeleteCatalog(ctx context.Context, id string) error
	UpsertSpec(ctx context.Context, catalogID string, spec apicatalog.SpecEntry) error
	GetSpec(ctx context.Context, catalogID, specName string) (*apicatalog.SpecEntry, error)
	ListSpecs(ctx context.Context, catalogID string) ([]apicatalog.SpecEntry, error)
	DeleteSpec(ctx context.Context, catalogID, specName string) error
	ReferencingConnections(ctx context.Context, catalogID string) ([]apicatalog.ConnectionRef, error)
	UpsertOperationEmbeddings(ctx context.Context, catalogID, specName string, rows []apicatalog.OperationEmbedding) error
	ListOperationEmbeddings(ctx context.Context, catalogID, specName string) ([]apicatalog.OperationEmbedding, error)
	DeleteOperationEmbeddings(ctx context.Context, catalogID, specName string) error
	SetOperationCount(ctx context.Context, catalogID, specName string, count int) error
}

CatalogStore is the subset of apigateway/catalog.Store these routes need. Declared here rather than against the concrete store so the apigateway toolkit's other dependencies (auth-events writer, embedding provider) do not become this seam's — or its parent's — transitive concern. pkg/admin aliases this as its exported APICatalogStore.

type Config

type Config struct {
	// Catalogs persists OpenAPI spec bundles. nil disables every route in
	// this package.
	Catalogs CatalogStore
	// EmbedJobs is the Postgres-backed embedding job queue. nil (no
	// database) disables the embedding visibility and retry routes; spec
	// writes still succeed without persisting embeddings.
	EmbedJobs catalogindex.Store
	// Reload broadcasts a catalog change to peer replicas. nil skips the
	// broadcast.
	Reload CatalogReloader
	// Toolkits is the live toolkit registry used to reload this replica's
	// api-gateway instances after a catalog mutation.
	Toolkits ToolkitReloader
	// Mutable reports database config mode; false registers the read
	// routes only, matching the other admin configuration surfaces.
	Mutable bool
	// Author resolves the acting admin for audit columns.
	Author func(*http.Request) string
	// Decode is the parent's strict JSON body decoder (unknown fields
	// rejected, size-capped); its error text is safe to return as the
	// problem detail.
	Decode func(w http.ResponseWriter, r *http.Request, dst any) error
	// DecodeLimit is Decode with a caller-supplied body cap, used by the
	// inline-spec write path whose `content` field legitimately carries
	// the same payload the multipart route allows up to 10 MiB.
	DecodeLimit func(w http.ResponseWriter, r *http.Request, dst any, maxBytes int64) error
}

Config carries the stores and parent-owned helpers these routes need.

type ToolkitReloader

type ToolkitReloader interface {
	All() []registry.Toolkit
}

ToolkitReloader is the live-registry side of the same fan-out: the local replica's api-gateway toolkits are reloaded in-process.

Jump to

Keyboard shortcuts

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