config

package
v0.0.0-...-51ec7a6 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 10 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"`
	ReadinessConcurrency int           `yaml:"readiness_concurrency"`
	// RequestTransactionWait bounds how long a request waits for a request
	// transaction slot before being shed with 503. Admission is capped by the
	// connection pool, so a brief wait absorbs bursts that would otherwise be
	// rejected. Zero sheds immediately.
	RequestTransactionWait time.Duration `yaml:"request_transaction_wait"`
}

type JobsConfig

type JobsConfig struct {
	Enabled      bool   `yaml:"enabled"`
	DefaultQueue string `yaml:"default_queue"`
	Workers      int    `yaml:"workers"`
	// Queues adds or overrides independently capped worker pools by queue name.
	// Workers remains the backward-compatible cap for the default and mail queues.
	Queues          map[string]int `yaml:"queues"`
	ShutdownTimeout time.Duration  `yaml:"shutdown_timeout"`
}

func (JobsConfig) WorkerQueues

func (c JobsConfig) WorkerQueues(mailQueue string) map[string]int

WorkerQueues returns an isolated copy of the host worker allocation. Explicit queue caps override the legacy default used by the default and mail queues.

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"`
	ResourceAttributes map[string]string `yaml:"resource_attributes"`
}

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