27 lines
810 B
Go
27 lines
810 B
Go
package grib
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.intra.yksa.space/gsn/predictor/internal/pkg/errcodes"
|
|
env "github.com/caarlos0/env/v11"
|
|
)
|
|
|
|
type Config struct {
|
|
Dir string `env:"DIR" envDefault:"/tmp/grib"`
|
|
TTL time.Duration `env:"TTL" envDefault:"24h"`
|
|
CacheTTL time.Duration `env:"CACHE_TTL" envDefault:"1h"`
|
|
Parallel int `env:"PARALLEL" envDefault:"4"`
|
|
Timeout time.Duration `env:"TIMEOUT" envDefault:"30s"`
|
|
DatasetURL string `env:"DATASET_URL" envDefault:"https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod"`
|
|
}
|
|
|
|
func NewConfig() (*Config, error) {
|
|
cfg := &Config{}
|
|
if err := env.ParseWithOptions(cfg, env.Options{
|
|
PrefixTagName: "GSN_PREDICTOR_GRIB_",
|
|
}); err != nil {
|
|
return nil, errcodes.Wrap(err, "failed to parse GRIB config")
|
|
}
|
|
return cfg, nil
|
|
}
|