Documentation
¶
Overview ¶
Package config provides a factory for ConfigLoader implementations with multiple backends.
Use New() or NewFromConfig() to create a loaded config instance. The factory handles calling Load() internally, returning a ready-to-use ConfigLoader.
Example:
// Create a Viper config loader pointing at a config directory
cfg, err := config.New(config.KindViper, config.WithBaseDir("./configs"))
if err != nil {
log.Fatal(err)
}
port := cfg.GetInt("server.port")
// Create from config struct
c := config.DefaultConfig()
c.Viper.BaseDir = "./configs"
cfg, err := config.NewFromConfig(c)
Index ¶
- func New(kind Kind, opts ...options.Option[Config]) (interfaces.ConfigLoader, error)
- func NewFromConfig(cfg Config) (interfaces.ConfigLoader, error)
- func WithBaseDir(dir string) options.Option[Config]
- func WithEnvPrefix(prefix string) options.Option[Config]
- func WithEnvironment(env string) options.Option[Config]
- type Config
- type Kind
- type ViperConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(kind Kind, opts ...options.Option[Config]) (interfaces.ConfigLoader, error)
New creates a ConfigLoader of the specified kind with optional functional options. The loader is fully initialized (Load called internally). Returns an error if the kind is unknown or loading fails.
Example:
cfg, err := config.New(config.KindViper, config.WithBaseDir("./configs"))
if err != nil {
return err
}
port := cfg.GetInt("server.port")
func NewFromConfig ¶
func NewFromConfig(cfg Config) (interfaces.ConfigLoader, error)
NewFromConfig creates a ConfigLoader from a Config struct. The loader is fully initialized (Load called internally). Returns an error if the kind is unknown or loading fails.
func WithBaseDir ¶
WithBaseDir sets the directory containing config files.
func WithEnvPrefix ¶
WithEnvPrefix sets the prefix for environment variable binding (default: "SEARCH").
Types ¶
type Config ¶
type Config struct {
// Viper holds Viper-specific configuration.
Viper ViperConfig
// Kind specifies which config loader implementation to use.
Kind Kind
}
Config is the top-level configuration for the config loader factory.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default config with KindViper and sensible defaults.
type ViperConfig ¶
type ViperConfig struct {
// BaseDir is the directory containing base.yaml, {env}.yaml overlays, and secrets.yaml.
BaseDir string
// Env is the environment name (e.g., "dev", "staging", "prod") for overlay selection.
Env string
// Prefix is the environment variable prefix for automatic binding (default: "SEARCH").
Prefix string
}
ViperConfig holds Viper-specific configuration. This is a subset of viper.Config, adapted for the parent config package.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package schema is the typed-configuration composition seam: it composes the concern-grouped config sub-packages (currently schema/infra) into a per-service AppConfig, and is the single struct the env-binding derivation (viper.deriveEnvBindings) reflects over to bind each field's SEARCH_<PATH> var from its mapstructure tag.
|
Package schema is the typed-configuration composition seam: it composes the concern-grouped config sub-packages (currently schema/infra) into a per-service AppConfig, and is the single struct the env-binding derivation (viper.deriveEnvBindings) reflects over to bind each field's SEARCH_<PATH> var from its mapstructure tag. |
|
infra
Package infra provides typed configuration structures for Tech AI Knowledge Engine services.
|
Package infra provides typed configuration structures for Tech AI Knowledge Engine services. |
|
listquery
Package listquery is the config surface for the List-Query Platform's scale path the value-suggestion facet knobs — the row threshold above which a facet-eligible field is served from the maintained distinct_values table instead of a live DISTINCT, and the interval at which the reconcile job recomputes refcounts.
|
Package listquery is the config surface for the List-Query Platform's scale path the value-suggestion facet knobs — the row threshold above which a facet-eligible field is served from the maintained distinct_values table instead of a live DISTINCT, and the interval at which the reconcile job recomputes refcounts. |
|
pipelines
Package pipelines is the config surface for the pipeline (orchestration) layer the per-pipeline operation timeout and the document upload multipart sizing.
|
Package pipelines is the config surface for the pipeline (orchestration) layer the per-pipeline operation timeout and the document upload multipart sizing. |
|
repos
Package repos is the config surface for the repository (data-access) layer the cache TTL/version/key-prefix and the per-operation timeout that were const in the repo decorator wiring.
|
Package repos is the config surface for the repository (data-access) layer the cache TTL/version/key-prefix and the per-operation timeout that were const in the repo decorator wiring. |
|
resilience
Package resilience is the tunable config surface for the foundation resilience decorators (retry, breaker, rate-limit, bulkhead, timeout, budget) — the per-environment knobs threaded through the repo/client/interceptor providers Each struct mirrors its primitive's tunable fields with defaults identical to the primitive's DefaultConfig(), so adopting the config surface is behavior-preserving; the providers convert these into the primitive's options.
|
Package resilience is the tunable config surface for the foundation resilience decorators (retry, breaker, rate-limit, bulkhead, timeout, budget) — the per-environment knobs threaded through the repo/client/interceptor providers Each struct mirrors its primitive's tunable fields with defaults identical to the primitive's DefaultConfig(), so adopting the config surface is behavior-preserving; the providers convert these into the primitive's options. |
|
services
Package services is the config surface for the domain (services) layer the document business limits — upload size ceiling and bulk-count cap — that were scattered consts.
|
Package services is the config surface for the domain (services) layer the document business limits — upload size ceiling and bulk-count cap — that were scattered consts. |
|
stores
Package stores is the config surface for the data (stores) layer the page-size cap + per-resource default page sizes that were scattered consts, so a deployer can tune pagination without a rebuild.
|
Package stores is the config surface for the data (stores) layer the page-size cap + per-resource default page sizes that were scattered consts, so a deployer can tune pagination without a rebuild. |
|
transport
Package transport is the config surface for the edge (transport) layer WebSocket/gRPC/CORS/HTTP tuning, the rate-limiter toggle that finally activates the token limiter, interceptor toggles, and the identity-client timeouts.
|
Package transport is the config surface for the edge (transport) layer WebSocket/gRPC/CORS/HTTP tuning, the rate-limiter toggle that finally activates the token limiter, interceptor toggles, and the identity-client timeouts. |
|
workers
Package workers is the shared config surface for the worker tier it generalizes the document-events WorkerConfig — the maturity reference with the sweep-timing cross-field invariant — so every worker inherits the typed-field + Validate shape (gate/jobs/services/clients tunables).
|
Package workers is the shared config surface for the worker tier it generalizes the document-events WorkerConfig — the maturity reference with the sweep-timing cross-field invariant — so every worker inherits the typed-field + Validate shape (gate/jobs/services/clients tunables). |
|
workflows
Package workflows is the config surface for the workflow (orchestration) layer the per-workflow operation timeout that the workflow.Builder.WithTimeout support exposes but no app sets today.
|
Package workflows is the config surface for the workflow (orchestration) layer the per-workflow operation timeout that the workflow.Builder.WithTimeout support exposes but no app sets today. |
|
Package viper provides a Viper-backed ConfigLoader implementation.
|
Package viper provides a Viper-backed ConfigLoader implementation. |