Documentation
¶
Overview ¶
Package config provides application configuration through environment variables.
Index ¶
Constants ¶
View Source
const ( DefaultServerHost = "0.0.0.0" DefaultServerPort = 8080 DefaultServerShutdownTimeout = 10 // seconds DefaultDBDriver = "postgres" DefaultDBConnectionString = "postgres://user:password@localhost:5432/mydb?sslmode=disable" //nolint:gosec DefaultDBMaxOpenConnections = 25 DefaultDBMaxIdleConnections = 5 DefaultDBConnMaxLifetime = 5 // minutes DefaultLogLevel = "info" DefaultAuthTokenExpiration = 14400 // seconds DefaultRateLimitEnabled = true DefaultRateLimitRequests = 10.0 DefaultRateLimitBurst = 20 DefaultRateLimitTokenEnabled = true DefaultRateLimitTokenRequests = 5.0 DefaultRateLimitTokenBurst = 10 DefaultCORSEnabled = false DefaultCORSAllowOrigins = "" DefaultMetricsEnabled = true DefaultMetricsNamespace = "secrets" DefaultMetricsPort = 8081 DefaultLockoutMaxAttempts = 10 DefaultLockoutDuration = 30 // minutes )
Default configuration values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ServerHost is the host address the server will bind to.
ServerHost string
// ServerPort is the port number the server will listen on.
ServerPort int
// ServerShutdownTimeout is the maximum time to wait for the server to gracefully shutdown.
ServerShutdownTimeout time.Duration
// DBDriver is the database driver to use (e.g., "postgres", "mysql").
DBDriver string
// DBConnectionString is the connection string for the database.
DBConnectionString string
// DBMaxOpenConnections is the maximum number of open connections to the database.
DBMaxOpenConnections int
// DBMaxIdleConnections is the maximum number of idle connections in the database pool.
DBMaxIdleConnections int
// DBConnMaxLifetime is the maximum amount of time a connection may be reused.
DBConnMaxLifetime time.Duration
// LogLevel is the logging level (e.g., "debug", "info", "warn", "error", "fatal", "panic").
LogLevel string
// AuthTokenExpiration is the duration after which an authentication token expires.
AuthTokenExpiration time.Duration
// RateLimitEnabled indicates whether rate limiting for authenticated endpoints is enabled.
RateLimitEnabled bool
// RateLimitRequestsPerSec is the number of requests allowed per second for authenticated endpoints.
RateLimitRequestsPerSec float64
// RateLimitBurst is the burst size for authenticated endpoints rate limiting.
RateLimitBurst int
// RateLimitTokenEnabled indicates whether rate limiting for the token endpoint is enabled.
RateLimitTokenEnabled bool
// RateLimitTokenRequestsPerSec is the number of requests allowed per second for the token endpoint.
RateLimitTokenRequestsPerSec float64
// RateLimitTokenBurst is the burst size for the token endpoint rate limiting.
RateLimitTokenBurst int
// CORSEnabled indicates whether CORS is enabled.
CORSEnabled bool
// CORSAllowOrigins is a comma-separated list of allowed origins for CORS.
CORSAllowOrigins string
// MetricsEnabled indicates whether metrics collection is enabled.
MetricsEnabled bool
// MetricsNamespace is the namespace for the application metrics.
MetricsNamespace string
// MetricsPort is the port number for the metrics server.
MetricsPort int
// KMSProvider is the KMS provider to use (e.g., "google", "aws", "azure", "hashivault", "localsecrets").
KMSProvider string
// KMSKeyURI is the URI for the master key in the KMS.
KMSKeyURI string
// LockoutMaxAttempts is the maximum number of failed login attempts before a lockout.
LockoutMaxAttempts int
// LockoutDuration is the duration for which an account is locked out after maximum attempts.
LockoutDuration time.Duration
}
Config holds all application configuration.
func (*Config) GetGinMode ¶
GetGinMode returns the appropriate Gin mode based on log level.
Click to show internal directories.
Click to hide internal directories.