package database import "git.linuxforward.com/byom/byom-golang-lib/pkg/errors" // Config holds the database configuration type Config struct { Path string `yaml:"path"` MaxOpenConns int `yaml:"max_open_conns"` MaxIdleConns int `yaml:"max_idle_conns"` ConnMaxLifetime int `yaml:"conn_max_lifetime"` Pragmas []string `yaml:"pragmas"` } // Validate implements the config.Validator interface func (c *Config) Validate() error { if c.Path == "" { return errors.NewConfigError("database.path", errors.ErrInvalidInput) } if c.MaxOpenConns == 0 { c.MaxOpenConns = 1 // SQLite recommendation } if c.MaxIdleConns == 0 { c.MaxIdleConns = 1 } if c.ConnMaxLifetime == 0 { c.ConnMaxLifetime = 300 // 5 minutes } return nil }