configsnapshot

package
v0.30.3 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: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthReader

type AuthReader interface {
	List(ctx context.Context, filter authdomain.ListFilter) ([]*authdomain.Auth, int, error)
}

type CatalogReader

type CatalogReader interface {
	ListProviders(ctx context.Context) ([]catalogdomain.Provider, error)
	ListModelsByProviderCode(ctx context.Context, providerCode string) ([]catalogdomain.Model, error)
}

type Compiler

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

func NewCompiler

func NewCompiler(
	gateways GatewayReader,
	consumers ConsumerReader,
	registries RegistryReader,
	policies PolicyReader,
	auths AuthReader,
	roles RoleReader,
	catalog CatalogReader,
	logger *slog.Logger,
) *Compiler

func (*Compiler) Compile

func (c *Compiler) Compile(ctx context.Context) (*readmodel.Snapshot, error)

func (*Compiler) CompileAll

CompileAll compiles the global snapshot, one tenant-only snapshot per gateway scope, and the shared catalog as its own snapshot. The catalog (providers + models, usually the bulk of the encoded bytes) is deliberately NOT merged into the global or scoped snapshots: the dispatcher encodes it once and appends the encoded bytes to every snapshot it publishes, instead of re-encoding the same catalog per gateway on every compile.

func (*Compiler) CompileFor

func (c *Compiler) CompileFor(ctx context.Context, scope string) (*readmodel.Snapshot, error)

type ConsumerReader

type ConsumerReader interface {
	ListByGateway(ctx context.Context, gatewayID ids.GatewayID) ([]*consumerdomain.Consumer, error)
	// List with a zero GatewayID pages across every gateway; the compiler's
	// bulk collect path uses it to load all consumers in one scan.
	List(ctx context.Context, filter consumerdomain.ListFilter) ([]*consumerdomain.Consumer, int, error)
}

type Dispatcher

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

Dispatcher compiles the config snapshot, holds it for the gRPC server to serve, broadcasts the new version to connected data planes, and drains the change-marker outbox that survives a control-plane restart. A committed admin write leaves a durable marker; the dispatcher folds every marker visible before the compile into one recompile and drains exactly that observed set.

func NewDispatcher

NewDispatcher builds the control-plane snapshot dispatcher.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(ctx context.Context) error

Dispatch runs one dispatch cycle synchronously. It must not run concurrently with Run or another Dispatch: the outbox frontier (MaxSeq/DeleteUpTo) is not mutually exclusive across cycles, so overlapping callers could drain against different frontiers.

func (*Dispatcher) Run

func (d *Dispatcher) Run(ctx context.Context) error

Run drives the dispatch loop until ctx is cancelled: an immediate dispatch on the first Signal after a quiet period so a single admin write (a new consumer, key, …) reaches data planes without sitting out the debounce, a trailing debounced dispatch that folds the rest of a Signal burst, a jittered backstop dispatch, and an initial catch-up when the outbox holds markers left by a write that committed before a prior restart.

func (*Dispatcher) Signal

func (d *Dispatcher) Signal()

Signal requests a dispatch after an admin write: immediate when the loop is quiet, folded into the trailing debounced dispatch during a write burst.

type DispatcherConfig

type DispatcherConfig struct {
	Debounce  time.Duration
	Backstop  time.Duration
	Retention time.Duration
	MaxRows   int
}

DispatcherConfig tunes the debounce/backstop cadence and the outbox safety bound.

type GatewayReader

type GatewayReader interface {
	List(ctx context.Context, filter gatewaydomain.ListFilter) ([]*gatewaydomain.Gateway, int, error)
}

type Holder

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

func NewHolder

func NewHolder() *Holder

func (*Holder) Set

func (h *Holder) Set(raw []byte, version string)

func (*Holder) SetPartitioned

func (h *Holder) SetPartitioned(raw []byte, version string, scoped map[string]ScopedSnapshot)

func (*Holder) Snapshot

func (h *Holder) Snapshot() (raw []byte, version string, ok bool)

func (*Holder) SnapshotFor

func (h *Holder) SnapshotFor(scope string) (raw []byte, version string, ok bool)

func (*Holder) Version

func (h *Holder) Version() string

type PartitionedCompiler

type PartitionedCompiler interface {
	CompileAll(ctx context.Context) (global *readmodel.Snapshot, scoped map[string]*readmodel.Snapshot, catalog *readmodel.Snapshot, err error)
}

PartitionedCompiler compiles the global snapshot, tenant-only scoped snapshots, and the shared catalog separately, so the dispatcher can encode the catalog once and append the encoded bytes to every published snapshot. Protobuf wire format merges concatenated messages (repeated fields append), so tenant bytes + catalog bytes decode as one full snapshot on the data plane; both halves use deterministic marshaling, keeping version hashes stable across replicas.

type PolicyReader

type PolicyReader interface {
	ListByGateway(ctx context.Context, gatewayID ids.GatewayID) ([]*policydomain.Policy, error)
	// List with a zero GatewayID pages across every gateway; the compiler's
	// bulk collect path uses it to load all policies in one scan.
	List(ctx context.Context, filter policydomain.ListFilter) ([]*policydomain.Policy, int, error)
}

type RegistryReader

type RegistryReader interface {
	List(ctx context.Context, filter registrydomain.ListFilter) ([]*registrydomain.Registry, int, error)
}

type RoleReader

type RoleReader interface {
	ListByGateway(ctx context.Context, gatewayID ids.GatewayID) ([]*roledomain.Role, error)
	// List with a zero GatewayID pages across every gateway; the compiler's
	// bulk collect path uses it to load all roles in one scan.
	List(ctx context.Context, filter roledomain.ListFilter) ([]*roledomain.Role, int, error)
}

type ScopedSnapshot

type ScopedSnapshot struct {
	Raw     []byte
	Version string
}

type Signaler

type Signaler interface {
	Signal()
}

type SnapshotCompiler

type SnapshotCompiler interface {
	Compile(ctx context.Context) (*readmodel.Snapshot, error)
}

SnapshotCompiler compiles the current State-of-the-World from the live config.

type SnapshotVersionPublisher

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

func NewSnapshotVersionPublisher

func NewSnapshotVersionPublisher(signaler Signaler) *SnapshotVersionPublisher

func (*SnapshotVersionPublisher) Signal

Jump to

Keyboard shortcuts

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