config

package
v0.0.0-...-d364ca2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads and validates Soro's typed application configuration.

Index

Constants

View Source
const (
	Development = "development"
	Test        = "test"
	Production  = "production"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Name        string `yaml:"name"`
	Version     string `yaml:"version"`
	Environment string `yaml:"environment"`
}

type Config

type Config struct {
	App           AppConfig           `yaml:"app"`
	Log           LogConfig           `yaml:"log"`
	HTTP          HTTPConfig          `yaml:"http"`
	Database      DatabaseConfig      `yaml:"database"`
	Jobs          JobsConfig          `yaml:"jobs"`
	Mail          MailConfig          `yaml:"mail"`
	Observability ObservabilityConfig `yaml:"observability"`
}

func Defaults

func Defaults() Config

func Load

func Load(options ...LoadOption) (*Config, error)

func (Config) Validate

func (c Config) Validate() error

type DatabaseConfig

type DatabaseConfig struct {
	URL              string        `yaml:"url"`
	MinConns         int32         `yaml:"min_conns"`
	MaxConns         int32         `yaml:"max_conns"`
	ConnectTimeout   time.Duration `yaml:"connect_timeout"`
	MaxConnLifetime  time.Duration `yaml:"max_conn_lifetime"`
	MaxConnIdleTime  time.Duration `yaml:"max_conn_idle_time"`
	HealthCheckEvery time.Duration `yaml:"health_check_period"`
}

type HTTPConfig

type HTTPConfig struct {
	Port              int           `yaml:"port"`
	APIBasePath       string        `yaml:"api_base_path"`
	MaxRequestBody    int64         `yaml:"max_request_body"`
	ReadHeaderTimeout time.Duration `yaml:"read_header_timeout"`
	ReadTimeout       time.Duration `yaml:"read_timeout"`
	WriteTimeout      time.Duration `yaml:"write_timeout"`
	IdleTimeout       time.Duration `yaml:"idle_timeout"`
	ShutdownTimeout   time.Duration `yaml:"shutdown_timeout"`
	ReadinessTimeout  time.Duration `yaml:"readiness_timeout"`
}

type JobsConfig

type JobsConfig struct {
	Enabled         bool          `yaml:"enabled"`
	DefaultQueue    string        `yaml:"default_queue"`
	Workers         int           `yaml:"workers"`
	ShutdownTimeout time.Duration `yaml:"shutdown_timeout"`
}

type LoadOption

type LoadOption func(*loadOptions)

func WithDirectory

func WithDirectory(directory string) LoadOption

func WithEnvLookup

func WithEnvLookup(lookup func(string) (string, bool)) LoadOption

WithEnvLookup supports deterministic tests and process supervisors that own their environment representation.

type LogConfig

type LogConfig struct {
	Level  string `yaml:"level"`
	Format string `yaml:"format"`
}

type MailConfig

type MailConfig struct {
	Transport string     `yaml:"transport"`
	From      string     `yaml:"from"`
	Queue     string     `yaml:"queue"`
	SMTP      SMTPConfig `yaml:"smtp"`
}

type ObservabilityConfig

type ObservabilityConfig struct {
	Enabled      bool          `yaml:"enabled"`
	OTLPEndpoint string        `yaml:"otlp_endpoint"`
	OTLPTimeout  time.Duration `yaml:"otlp_timeout"`
}

type SMTPConfig

type SMTPConfig struct {
	Host               string        `yaml:"host"`
	Port               int           `yaml:"port"`
	Username           string        `yaml:"username"`
	Password           string        `yaml:"password"`
	StartTLS           bool          `yaml:"starttls"`
	ImplicitTLS        bool          `yaml:"implicit_tls"`
	InsecureSkipVerify bool          `yaml:"insecure_skip_verify"`
	Timeout            time.Duration `yaml:"timeout"`
}

Jump to

Keyboard shortcuts

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