configcore

package
v0.0.0-...-1779528 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package configcore implements the configcore Cell: configuration management with versioning, publishing, rollback, and feature flag evaluation.

cell_init.go hosts ConfigCore.initInternal() and the initXxxSlice helpers that construct the six slices during cell initialization. Constructor + options live in cell.go; Init() is generated in cell_gen.go.

Index

Constants

View Source
const VersionField = "version"

VersionField is the DB column name used as the CAS version field for optimistic-concurrency control on config entries and feature flags. Composition root uses this constant when wiring cas.Protocol:

cas.MustNewProtocol(cas.WithVersionField(configcore.VersionField))

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigCore

type ConfigCore struct {
	*cell.BaseCell
	// contains filtered or unexported fields
}

ConfigCore is the configcore Cell implementation. +cell:listener:ref=cell.PrimaryListener,prefix=/api/v1 +cell:listener:ref=cell.InternalListener,prefix=/internal/v1

func NewConfigCore

func NewConfigCore(opts ...Option) *ConfigCore

NewConfigCore creates a new ConfigCore Cell.

func (*ConfigCore) Init

func (c *ConfigCore) Init(ctx context.Context, reg cell.Registry) error

type Option

type Option func(*ConfigCore)

Option configures a ConfigCore Cell.

func WithCASProtocol

func WithCASProtocol(p *cas.Protocol) Option

WithCASProtocol sets the CAS protocol declaration for this Cell. Required in durable mode — initInternal() fails fast if nil. Both bare-nil and typed-nil *cas.Protocol values are rejected via sticky sentinel. Composition root constructs via cas.MustNewProtocol (CAS-PROTOCOL-COMPOSITION-ROOT-01); tests may inject a test-scoped *cas.Protocol.

ref: runtime/http/router WithRateLimiter — same strong-dependency wiring option pattern (option body sets sticky nil sentinel; phase0 validates).

func WithClock

func WithClock(clk clock.Clock) Option

WithClock sets the time source for this Cell. Required — Init() panics via clock.MustHaveClock if not set. Composition root passes clock.Real(); tests inject a deterministic clock to control time-sensitive logic.

func WithConfigEventCollector

func WithConfigEventCollector(collector obmetrics.ConfigEventCollector) Option

WithConfigEventCollector injects config-event consumer process metrics.

func WithConfigRepository

func WithConfigRepository(r ports.ConfigRepository) Option

WithConfigRepository sets the ConfigRepository.

func WithCursorCodec

func WithCursorCodec(codec *query.CursorCodec) Option

WithCursorCodec sets the cursor codec for pagination.

func WithEmitter

func WithEmitter(e outbox.Emitter) Option

WithEmitter injects a pre-composed outbox.Emitter directly into the Cell. Preferred path for tests and for composition roots that have already built an Emitter.

Mutually exclusive with WithOutboxDeps — setting both causes Init() to fail fast with ErrCellInvalidConfig. Durability for L2 slice decisions is derived from outbox.ReportDurable(emitter); emitters that do not implement DurabilityReporter are treated as non-durable.

ref: kubernetes/client-go rest.RESTClientFor — factory composes the typed client; resulting struct does not retain raw config fields.

func WithFlagRepository

func WithFlagRepository(r ports.FlagRepository) Option

WithFlagRepository sets the FlagRepository.

func WithInMemoryDefaults

func WithInMemoryDefaults() Option

WithInMemoryDefaults configures in-memory repositories for development and testing. Not suitable for production use. Repository construction is deferred to Init() so that c.clk is available when mem.NewConfigRepository/NewFlagRepository are called.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets the structured logger.

func WithMetricsProvider

func WithMetricsProvider(p metrics.Provider) Option

WithMetricsProvider sets the metrics provider used by the DirectEmitter in demo mode. Required when WithOutboxDeps sets a publisher without a real outboxWriter. Pass metrics.NopProvider{} explicitly in tests.

func WithOutboxDeps

func WithOutboxDeps(pub outbox.CellPublisher, writer outbox.CellWriter) Option

WithOutboxDeps wires sealed outbox dependencies (CellPublisher + CellWriter). Composition roots construct each via outbox.WrapPublisherForCell / outbox.WrapWriterForCell. The framework composes them into an outbox.Emitter at Init() time via cell.ResolveCellEmitter.

Accumulative: a nil argument leaves the previously-set value in place; multiple calls combine their non-nil arguments. Does NOT clear previous state — `WithOutboxDeps(nil, nil)` is a no-op, not a reset. Mutually exclusive with WithEmitter; Init() fails fast if both are set.

AI-HARD per ADR cell-raw-infra-sealed-marker: the option signature rejects raw outbox.Publisher / outbox.Writer at compile time.

func WithTxManager

func WithTxManager(tx persistence.CellTxManager) Option

WithTxManager sets the CellTxManager for transactional guarantees (L2 atomicity). Composition roots construct via persistence.WrapForCell.

Directories

Path Synopsis
internal
adapters/postgres
Package postgres provides a PostgreSQL implementation of configcore ports.
Package postgres provides a PostgreSQL implementation of configcore ports.
crypto
Package crypto provides configcore-specific crypto helpers.
Package crypto provides configcore-specific crypto helpers.
domain
Package domain contains the configcore Cell domain models.
Package domain contains the configcore Cell domain models.
dto
Package dto provides shared handler-level data transfer objects for configcore.
Package dto provides shared handler-level data transfer objects for configcore.
events
Package events defines configcore's internal event wire payloads and decoders.
Package events defines configcore's internal event wire payloads and decoders.
mem
Package mem provides in-memory repository implementations for configcore.
Package mem provides in-memory repository implementations for configcore.
ports
Package ports defines the driven-side interfaces for configcore.
Package ports defines the driven-side interfaces for configcore.
testutil
Package testutil provides test doubles and helpers scoped to the configcore cell.
Package testutil provides test doubles and helpers scoped to the configcore cell.
Package postgres wires PostgreSQL-backed repositories for configcore.
Package postgres wires PostgreSQL-backed repositories for configcore.
slices
configpublish
Package configpublish — PublishFailureMode type.
Package configpublish — PublishFailureMode type.
configread
Package configread implements the config-read slice: Get/List config entries.
Package configread implements the config-read slice: Get/List config entries.
configsubscribe
Package configsubscribe implements the config-subscribe slice: consumes config state-sync events to update a local version-tracking cache.
Package configsubscribe implements the config-subscribe slice: consumes config state-sync events to update a local version-tracking cache.
configwrite
Package configwrite implements the config-write slice: Create/Update/Delete config entries with event publishing.
Package configwrite implements the config-write slice: Create/Update/Delete config entries with event publishing.
featureflag
Package featureflag implements the feature-flag slice: Get/Evaluate feature flags.
Package featureflag implements the feature-flag slice: Get/Evaluate feature flags.
flagwrite
Package flagwrite implements the flag-write slice: Create/Update/Delete/Toggle feature flags with transactional repo writes (L1 consistency).
Package flagwrite implements the flag-write slice: Create/Update/Delete/Toggle feature flags with transactional repo writes (L1 consistency).

Jump to

Keyboard shortcuts

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