Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAppConfigModule ¶
func NewAppConfigModule(opts ...AppConfigOption) fx.Option
NewAppConfigModule creates an fx module for application configuration. By default, loads from environment variables (APP_ENV, APP_SERVICE_NAME, APP_SERVICE_VERSION). Use WithAppConfig for static config (useful for tests).
func NewDotEnvModule ¶ added in v0.4.3
func NewDotEnvModule(opts ...DotEnvOption) fx.Option
NewDotEnvModule loads environment variables from a .env file. By default, loads from ".env" in the current directory. Loading happens synchronously when the module is created.
func NewKoanfModule ¶ added in v0.5.5
func NewKoanfModule(opts ...KoanfOption) fx.Option
NewKoanfModule creates an fx module for Koanf configuration.
Configuration is loaded in order (later overrides earlier):
- YAML config file (from CONFIG_FILE env or WithKoanfConfigPath)
- Environment variables
Env convention: use __ (double underscore) as level delimiter, single _ as word separator.
OBSERVABILITY__OTEL_COLLECTOR_ENDPOINT → observability.otel-collector-endpoint MONGO__MAX_POOL_SIZE → mongo.max-pool-size LOGGER__LEVEL → logger.level
Types ¶
type AppConfig ¶
type AppConfig struct {
ServiceName string
ServiceVersion string
// Environment is the deployment environment (e.g., "local", "staging", "pro")
Environment string
IsKubernetes bool
}
AppConfig represents the core application metadata.
type AppConfigOption ¶ added in v0.4.3
type AppConfigOption func(*appConfigOptions)
AppConfigOption is a functional option for configuring the AppConfig module.
func WithAppConfig ¶ added in v0.4.3
func WithAppConfig(cfg AppConfig) AppConfigOption
WithAppConfig provides a static AppConfig (useful for tests).
type DotEnvOption ¶ added in v0.4.3
type DotEnvOption func(*dotenvConfig)
DotEnvOption is a functional option for configuring the dotenv module.
func WithDotEnvPath ¶ added in v0.4.3
func WithDotEnvPath(path string) DotEnvOption
WithDotEnvPath sets a custom path to the .env file.
type KoanfOption ¶ added in v0.5.5
type KoanfOption func(*koanfOptions)
KoanfOption is a functional option for configuring the Koanf module.
func WithKoanfConfigPath ¶ added in v0.5.5
func WithKoanfConfigPath(path string) KoanfOption
WithKoanfConfigPath sets a direct path to the configuration file.
func WithoutKoanfConfigFile ¶ added in v0.5.5
func WithoutKoanfConfigFile() KoanfOption
WithoutKoanfConfigFile disables loading of any config file.