Documentation
¶
Overview ¶
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). Slices may not import each other, so the read logic lives here and each slice type-aliases configreader.Service. This mirrors cells/auditcore/internal/appender.
The split is enforced by governance rule SLICE-HTTP-VISIBILITY-SEGREGATION-01 (FMT-33): a single slice must not serve both public and internal HTTP contracts.
configread.Service and configreadinternal.Service are type aliases (not interfaces): both slices call identical methods with zero divergence, so an interface + separate impl would add indirection with no benefit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements config read business logic shared by the public and internal read slices.
func NewService ¶
func NewService( repo ports.ConfigRepository, txRunner persistence.CellTxManager, codec *query.CursorCodec, logger *slog.Logger, sliceName string, runMode query.RunMode, ) (*Service, error)
NewService creates a config-read Service. sliceName identifies the owning slice in observability labels (e.g. "configread" or "configreadinternal"); each slice must create its own Service instance so that cursor-error logs and query-context labels can be attributed to the correct slice.
runMode controls cursor fail-open vs fail-closed semantics; pass query.RunModeProd unless the assembly declares DurabilityDemo.
codec must be non-nil — pagination cannot be served without a cursor codec. Passing nil is a caller programming error; NewService returns errcode.ErrCellMissingCodec so the cell Init() can propagate a structured error instead of a runtime panic.
func (*Service) GetByKey ¶
func (s *Service) GetByKey(ctx context.Context, t tenant.TenantID, key string) (*domain.ConfigEntry, error)
GetByKey retrieves a config entry by key within the tenant scope t. The caller sources t differently per trust boundary: the public configread handler derives it from the authenticated principal (tenant.FromContext); the internal configreadinternal handler derives it from the X-Tenant-ID request header. Sourcing happens in the slice handler, never here, so this shared Service stays tenant-source-agnostic.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, t tenant.TenantID, pageReq query.PageParams) (query.PageResult[*domain.ConfigEntry], error)
List returns a paginated page of config entries within the tenant scope t. See GetByKey for how t is sourced per trust boundary.