config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostgreSQL = "postgresql"
	Oracle     = "oracle"
)

Database type constants

Variables

This section is empty.

Functions

func Validate

func Validate(cfg *Config) error

Types

type AppConfig

type AppConfig struct {
	Name      string `koanf:"name"`
	Version   string `koanf:"version"`
	Env       string `koanf:"env"`
	Debug     bool   `koanf:"debug"`
	RateLimit int    `koanf:"rate_limit"`
	Namespace string `koanf:"namespace"`
}

type Config

type Config struct {
	App       AppConfig       `koanf:"app"`
	Server    ServerConfig    `koanf:"server"`
	Database  DatabaseConfig  `koanf:"database"`
	Log       LogConfig       `koanf:"log"`
	Messaging MessagingConfig `koanf:"messaging"`
}

func Load

func Load() (*Config, error)

Load loads configuration from multiple sources with priority: 1. Environment variables (highest priority) 2. YAML configuration files 3. Default values (lowest priority)

type DatabaseConfig

type DatabaseConfig struct {
	Type            string        `koanf:"type"` // "postgresql" or "oracle"
	Host            string        `koanf:"host"`
	Port            int           `koanf:"port"`
	Database        string        `koanf:"database"`
	Username        string        `koanf:"username"`
	Password        string        `koanf:"password"`
	SSLMode         string        `koanf:"ssl_mode"`
	MaxConns        int32         `koanf:"max_conns"`
	MaxIdleConns    int32         `koanf:"max_idle_conns"`
	ConnMaxLifetime time.Duration `koanf:"conn_max_lifetime"`
	ConnMaxIdleTime time.Duration `koanf:"conn_max_idle_time"`

	// Oracle-specific settings
	ServiceName string `koanf:"service_name"` // Oracle service name
	SID         string `koanf:"sid"`          // Oracle SID

	// Connection string override (if needed)
	ConnectionString string `koanf:"connection_string"`
}

type LogConfig

type LogConfig struct {
	Level  string `koanf:"level"`
	Pretty bool   `koanf:"pretty"`
}

type MessagingConfig

type MessagingConfig struct {
	BrokerURL   string            `koanf:"broker_url"`
	Exchange    string            `koanf:"exchange"`
	RoutingKey  string            `koanf:"routing_key"`
	VirtualHost string            `koanf:"virtual_host"`
	Headers     map[string]string `koanf:"headers"`
}

type ServerConfig

type ServerConfig struct {
	Host              string        `koanf:"host"`
	Port              int           `koanf:"port"`
	ReadTimeout       time.Duration `koanf:"read_timeout"`
	WriteTimeout      time.Duration `koanf:"write_timeout"`
	MiddlewareTimeout time.Duration `koanf:"middleware_timeout"`
	ShutdownTimeout   time.Duration `koanf:"shutdown_timeout"`
}

Jump to

Keyboard shortcuts

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