config
import "github.com/afreidah/g3/internal/config"
Index
func ParseLogLevel
func ParseLogLevel(level string) slog.Level
ParseLogLevel converts a log level string to slog.Level.
type BucketConfig
BucketConfig defines an S3 bucket and its access credentials.
type BucketConfig struct {
Name string `yaml:"name"`
Credentials []CredentialConfig `yaml:"credentials"`
}
type Config
Config is the root configuration for g3.
type Config struct {
Server ServerConfig `yaml:"server"`
Gmail GmailConfig `yaml:"gmail"`
Database DatabaseConfig `yaml:"database"`
Buckets []BucketConfig `yaml:"buckets"`
Telemetry TelemetryConfig `yaml:"telemetry"`
}
func LoadConfig
func LoadConfig(path string) (*Config, error)
LoadConfig reads and parses a YAML config file with environment variable expansion. Variables are referenced as ${VAR_NAME} in the YAML file.
func (*Config) SetDefaultsAndValidate
func (c *Config) SetDefaultsAndValidate() error
SetDefaultsAndValidate applies defaults and validates the entire config tree. Returns an error listing all validation failures.
type CredentialConfig
CredentialConfig holds an S3-compatible access key pair.
type CredentialConfig struct {
AccessKeyID string `yaml:"access_key_id"`
SecretAccessKey string `yaml:"secret_access_key"`
}
type DatabaseConfig
DatabaseConfig holds metadata store settings.
type DatabaseConfig struct {
Driver string `yaml:"driver"`
Path string `yaml:"path"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Database string `yaml:"database"`
User string `yaml:"user"`
Password string `yaml:"password"`
SSLMode string `yaml:"ssl_mode"`
MaxConns int `yaml:"max_conns"`
}
type GmailConfig
GmailConfig holds Gmail API connection and behavior settings.
type GmailConfig struct {
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
RefreshToken string `yaml:"refresh_token"`
User string `yaml:"user"`
MaxAttachmentBytes int64 `yaml:"max_attachment_bytes"`
ChunkSizeBytes int64 `yaml:"chunk_size_bytes"`
LabelPrefix string `yaml:"label_prefix"`
}
type MetricsConfig
MetricsConfig controls the Prometheus metrics endpoint.
type MetricsConfig struct {
Enabled bool `yaml:"enabled"`
Path string `yaml:"path"`
}
type ServerConfig
ServerConfig holds HTTP server settings.
type ServerConfig struct {
ListenAddr string `yaml:"listen_addr"`
LogLevel string `yaml:"log_level"`
ReadTimeout time.Duration `yaml:"read_timeout"`
WriteTimeout time.Duration `yaml:"write_timeout"`
ShutdownTimeout time.Duration `yaml:"shutdown_timeout"`
}
type TelemetryConfig
TelemetryConfig holds metrics and tracing configuration.
type TelemetryConfig struct {
Metrics MetricsConfig `yaml:"metrics"`
Tracing telemetry.TracingConfig `yaml:"tracing"`
}
Generated by gomarkdoc