package downloader import ( "os" "strconv" "time" ) // Config holds downloader configuration, loaded from environment variables. type Config struct { // DataDir is the directory for storing dataset files and temporary GRIB data. DataDir string // Parallel is the maximum number of concurrent GRIB downloads. Parallel int // UpdateInterval is how often the scheduler checks for new forecast data. UpdateInterval time.Duration // DatasetTTL is how long a dataset is considered fresh before a new one is needed. DatasetTTL time.Duration } // DefaultConfig returns the default configuration. func DefaultConfig() *Config { return &Config{ DataDir: "/tmp/predictor-data", Parallel: 8, UpdateInterval: 6 * time.Hour, DatasetTTL: 48 * time.Hour, } } // LoadConfig loads configuration from environment variables, falling back to defaults. func LoadConfig() *Config { cfg := DefaultConfig() if v := os.Getenv("PREDICTOR_DATA_DIR"); v != "" { cfg.DataDir = v } if v := os.Getenv("PREDICTOR_DOWNLOAD_PARALLEL"); v != "" { if n, err := strconv.Atoi(v); err == nil && n > 0 { cfg.Parallel = n } } if v := os.Getenv("PREDICTOR_UPDATE_INTERVAL"); v != "" { if d, err := time.ParseDuration(v); err == nil { cfg.UpdateInterval = d } } if v := os.Getenv("PREDICTOR_DATASET_TTL"); v != "" { if d, err := time.ParseDuration(v); err == nil { cfg.DatasetTTL = d } } return cfg }