configs

package
v0.0.0-...-db77838 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configs loads and validates static application configuration.

Index

Constants

View Source
const (
	// DefaultAppName is returned by /api/info when config omits app.name.
	DefaultAppName = "echo-admin"

	// DefaultPort is the HTTP port used when config omits system.port.
	DefaultPort = ":9322"

	// LogFormatConsole writes human-readable zerolog console output.
	LogFormatConsole = "console"

	// LogFormatJSON writes structured zerolog JSON output.
	LogFormatJSON = "json"

	// LogOutputStdout writes logs to standard output.
	LogOutputStdout = "stdout"

	// LogOutputStderr writes logs to standard error.
	LogOutputStderr = "stderr"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminConfig

type AdminConfig struct {
	UploadDir string `mapstructure:"upload_dir"`
}

AdminConfig controls back-office runtime behavior.

type AppConfig

type AppConfig struct {
	Name    string `mapstructure:"name"`
	Version string `mapstructure:"version"`
}

AppConfig controls process identity exposed by system routes.

type CORSConfig

type CORSConfig struct {
	Enabled          bool     `mapstructure:"enabled"`
	AllowOrigins     []string `mapstructure:"allow_origins"`
	AllowMethods     []string `mapstructure:"allow_methods"`
	AllowHeaders     []string `mapstructure:"allow_headers"`
	AllowCredentials bool     `mapstructure:"allow_credentials"`
	ExposeHeaders    []string `mapstructure:"expose_headers"`
	MaxAgeSeconds    int      `mapstructure:"max_age_seconds"`
}

CORSConfig controls optional CORS middleware.

type Config

type Config struct {
	App     AppConfig     `mapstructure:"app"`
	System  SystemConfig  `mapstructure:"system"`
	Log     LogConfig     `mapstructure:"log"`
	HTTP    HTTPConfig    `mapstructure:"http"`
	Admin   AdminConfig   `mapstructure:"admin"`
	MySQL   MySQLConfig   `mapstructure:"mysql"`
	Redis   RedisConfig   `mapstructure:"redis"`
	MongoDB MongoDBConfig `mapstructure:"mongodb"`
	Tracing TracingConfig `mapstructure:"tracing"`
}

Config is the complete application configuration loaded at startup.

func Load

func Load(path string) (Config, error)

Load reads a static application config file and applies supported environment variable overrides. It is the single owner of normalization and validation: the returned Config is final for every downstream consumer, which must not re-normalize or re-validate it.

type HTTPConfig

type HTTPConfig struct {
	EnableRecovery       bool       `mapstructure:"enable_recovery"`
	EnableRequestContext bool       `mapstructure:"enable_request_context"`
	EnableRequestLog     bool       `mapstructure:"enable_request_log"`
	EnableGzip           bool       `mapstructure:"enable_gzip"`
	SecureCookies        bool       `mapstructure:"secure_cookies"`
	CORS                 CORSConfig `mapstructure:"cors"`
}

HTTPConfig controls server-owned HTTP middleware. The Enable* booleans default to true via defaultConfig: omitting a key keeps the middleware installed, an explicit false opts out, and the environment can override both.

type Level

type Level int8

Level identifies the runtime logging and debug mode.

const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = iota + 1
	// OnlineLevel is the default production priority.
	OnlineLevel
)

type LogConfig

type LogConfig struct {
	Format string `mapstructure:"format"`
	Output string `mapstructure:"output"`
	Caller bool   `mapstructure:"caller"`
}

LogConfig controls process-level structured logging.

type MongoDBConfig

type MongoDBConfig struct {
	Enabled               bool   `mapstructure:"enabled"`
	URI                   string `mapstructure:"uri"`
	Database              string `mapstructure:"database"`
	ConnectTimeoutSeconds int    `mapstructure:"connect_timeout_seconds"`
	PingTimeoutSeconds    int    `mapstructure:"ping_timeout_seconds"`
}

MongoDBConfig controls the optional process-level MongoDB resource.

type MySQLConfig

type MySQLConfig struct {
	Enabled                bool   `mapstructure:"enabled"`
	Host                   string `mapstructure:"host"`
	Port                   int    `mapstructure:"port"`
	Database               string `mapstructure:"database"`
	Username               string `mapstructure:"username"`
	Password               string `mapstructure:"password"`
	MaxOpenConns           int    `mapstructure:"max_open_conns"`
	MaxIdleConns           int    `mapstructure:"max_idle_conns"`
	ConnMaxLifetimeSeconds int    `mapstructure:"conn_max_lifetime_seconds"`
	PingTimeoutSeconds     int    `mapstructure:"ping_timeout_seconds"`
}

MySQLConfig controls the optional process-level MySQL resource.

type RedisConfig

type RedisConfig struct {
	Enabled             bool   `mapstructure:"enabled"`
	Address             string `mapstructure:"address"`
	Username            string `mapstructure:"username"`
	Password            string `mapstructure:"password"`
	DB                  int    `mapstructure:"db"`
	DialTimeoutSeconds  int    `mapstructure:"dial_timeout_seconds"`
	ReadTimeoutSeconds  int    `mapstructure:"read_timeout_seconds"`
	WriteTimeoutSeconds int    `mapstructure:"write_timeout_seconds"`
	PingTimeoutSeconds  int    `mapstructure:"ping_timeout_seconds"`
}

RedisConfig controls the optional process-level Redis resource.

type SystemConfig

type SystemConfig struct {
	Port  string `mapstructure:"port"`
	Level Level  `mapstructure:"level"`
}

SystemConfig controls process-level runtime settings.

type TracingConfig

type TracingConfig struct {
	Enabled                bool    `mapstructure:"enabled"`
	Endpoint               string  `mapstructure:"endpoint"`
	Protocol               string  `mapstructure:"protocol"`
	Insecure               bool    `mapstructure:"insecure"`
	ServiceName            string  `mapstructure:"service_name"`
	SampleRatio            float64 `mapstructure:"sample_ratio"`
	ShutdownTimeoutSeconds int     `mapstructure:"shutdown_timeout_seconds"`
}

TracingConfig controls optional OpenTelemetry export to Jaeger OTLP.

Jump to

Keyboard shortcuts

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