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 seven slices during cell initialization. Constructor + options live in cell.go; Init() is generated in cell_gen.go.
cell_lifecycle.go implements the optional cell-level lifecycle hooks (cell.AfterStarter / cell.BeforeStopper). The assembly discovers these via type assertion and invokes them around BaseCell.Start/Stop. ConfigCore uses them solely to bind the configsubscribe tombstone-GC goroutine to the cell lifecycle (start after the cell is up, drain before it stops) — no goroutine leak, no persistence. See docs/plans .../035 PR-CFG-CACHE-LIFECYCLE.
Index ¶
- Constants
- func RegisterReadiness(reg cell.Registrar, p healthz.RepoProber) error
- type ConfigCore
- type Option
- func WithCASProtocol(p *cas.Protocol) Option
- func WithConfigEventCollector(collector obmetrics.ConfigEventCollector) Option
- func WithConfigRepository(r ports.ConfigRepository) Option
- func WithCursorCodec(codec *query.CursorCodec) Option
- func WithEmitter(e outbox.CellEmitter) Option
- func WithEventbusCacheCollector(col obmetrics.EventbusCacheCollector) Option
- func WithFlagRepository(r ports.FlagRepository) Option
- func WithInMemoryDefaults() Option
- func WithLogger(l *slog.Logger) Option
- func WithMetricsProvider(p metrics.Provider) Option
- func WithOutboxDeps(pub outbox.CellPublisher, writer outbox.CellWriter) Option
- func WithTombstoneTTL(d time.Duration) Option
- func WithTxManager(tx persistence.CellTxManager) Option
Constants ¶
const ProbeRepoReady healthz.ProbeName = "configcore_repo_ready"
ProbeRepoReady is the canonical readiness probe name for the configcore cell's primary repository. The "_ready" suffix is required by the PROBENAME-SEALED-FUNNEL-01 convention.
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.NewProtocol(cas.WithVersionField(configcore.VersionField))
Variables ¶
This section is empty.
Functions ¶
func RegisterReadiness ¶
func RegisterReadiness(reg cell.Registrar, p healthz.RepoProber) error
RegisterReadiness registers a healthz.RepoProber implementation as the cell-level repository readiness probe on the given Registrar. This is the sole sanctioned entry point — handwritten cell code must NOT call reg.RegisterReadiness directly with a bare string (locked by PROBENAME-SEALED-FUNNEL-01).
Emitter health probes are NOT generated per-cell: they go through the shared kernel funnel cell.RegisterEmitterHealthProbes(reg, emitter), which handles the healthz.ProbeSet assertion and typed-nil guard in one place.
Types ¶
type ConfigCore ¶
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(clk clock.Clock, opts ...Option) *ConfigCore
NewConfigCore creates a new ConfigCore Cell.
func (*ConfigCore) AfterStart ¶
func (c *ConfigCore) AfterStart(context.Context) error
AfterStart launches the configsubscribe tombstone-GC sweep. Runs after BaseCell.Start succeeds (BeforeStart must not acquire resources needing cleanup; the GC goroutine needs cleanup, so it starts here).
func (*ConfigCore) BeforeStop ¶
func (c *ConfigCore) BeforeStop(ctx context.Context) error
BeforeStop signals the tombstone-GC goroutine and waits for it to drain, honoring ctx for the shutdown deadline. Idempotent / safe if never started.
type Option ¶
type Option func(*ConfigCore)
Option configures a ConfigCore Cell.
func WithCASProtocol ¶
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.NewProtocol (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 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.CellEmitter) Option
WithEmitter injects a pre-composed outbox.CellEmitter 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 WithEventbusCacheCollector ¶
func WithEventbusCacheCollector(col obmetrics.EventbusCacheCollector) Option
WithEventbusCacheCollector injects the subscriber-cache tombstone-GC metric collector. nil is normalized to NoopEventbusCacheCollector by the slice.
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 WithMetricsProvider ¶
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 outbox.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 WithTombstoneTTL ¶
WithTombstoneTTL sets the configsubscribe cache tombstone TTL. The cell forwards it to the configsubscribe service. 0, negative, or any value below the Claimer idempotency window (idempotency.DefaultTTL = 24h) is clamped up to that window by NewService — enforced invariant, not advisory. The tombstone-GC always runs; there is no API to disable it.
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 |
|---|---|
|
Package configcoretest provides testutil builders and fakes for the configcore cell.
|
Package configcoretest provides testutil builders and fakes for the configcore cell. |
|
internal
|
|
|
adapters/postgres
Package postgres provides a PostgreSQL implementation of configcore ports.
|
Package postgres provides a PostgreSQL implementation of configcore ports. |
|
configreader
Package configreader holds the shared config-read business logic (GetByKey / List) consumed by two sibling slices that sit on different HTTP trust boundaries: the public-facing `configread` slice (GET + list under /api/v1, admin-gated) and the internal control-plane `configreadinternal` slice (GET under /internal/v1, caller-cell gated).
|
Package configreader holds the shared config-read business logic (GetByKey / List) consumed by two sibling slices that sit on different HTTP trust boundaries: the public-facing `configread` slice (GET + list under /api/v1, admin-gated) and the internal control-plane `configreadinternal` slice (GET under /internal/v1, caller-cell gated). |
|
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. |
|
scopedread
Package scopedread funnels every tenant-scoped configcore read through a single tenant.WithScope + RunInTx wrapper.
|
Package scopedread funnels every tenant-scoped configcore read through a single tenant.WithScope + RunInTx wrapper. |
|
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 public config-read slice: GET + list of config entries under /api/v1/config (admin-gated).
|
Package configread implements the public config-read slice: GET + list of config entries under /api/v1/config (admin-gated). |
|
configreadinternal
Package configreadinternal implements the internal control-plane config-read slice: GET a config entry under /internal/v1/config, mounted on the InternalListener where service-token + caller-cell auth is enforced.
|
Package configreadinternal implements the internal control-plane config-read slice: GET a config entry under /internal/v1/config, mounted on the InternalListener where service-token + caller-cell auth is enforced. |
|
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). |