engine refactor
This commit is contained in:
parent
9e663db9dc
commit
81b8e763bd
37 changed files with 3532 additions and 1639 deletions
|
|
@ -19,11 +19,14 @@ import (
|
|||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"predictor-refactored/internal/api"
|
||||
"predictor-refactored/internal/api/async"
|
||||
"predictor-refactored/internal/config"
|
||||
"predictor-refactored/internal/datasets"
|
||||
"predictor-refactored/internal/datasets/gefs"
|
||||
"predictor-refactored/internal/datasets/gfs"
|
||||
"predictor-refactored/internal/elevation"
|
||||
"predictor-refactored/internal/metrics"
|
||||
wgfs "predictor-refactored/internal/weather/gfs"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -60,13 +63,23 @@ func run(args []string) error {
|
|||
return fmt.Errorf("init store: %w", err)
|
||||
}
|
||||
|
||||
// Source is GFS today; the spec leaves room for ECMWF later via the
|
||||
// same datasets.Source interface.
|
||||
if cfg.Data.Source != "noaa-gfs-0p50" {
|
||||
return fmt.Errorf("source %q not supported", cfg.Data.Source)
|
||||
variant, err := wgfs.VariantByID(cfg.Data.Source)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unsupported source %q: %w", cfg.Data.Source, err)
|
||||
}
|
||||
var source datasets.Source
|
||||
switch variant.Family {
|
||||
case wgfs.FamilyGFS:
|
||||
s := gfs.NewSource(variant, log)
|
||||
s.Parallel = cfg.Download.Parallel
|
||||
source = s
|
||||
case wgfs.FamilyGEFS:
|
||||
s := gefs.NewSource(variant, log)
|
||||
s.Parallel = cfg.Download.Parallel
|
||||
source = s
|
||||
default:
|
||||
return fmt.Errorf("unsupported family for %q", cfg.Data.Source)
|
||||
}
|
||||
source := gfs.NewSource(log)
|
||||
source.Parallel = cfg.Download.Parallel
|
||||
|
||||
var throttle datasets.Throttle
|
||||
if cfg.Download.BandwidthBytesPerSecond > 0 {
|
||||
|
|
@ -128,12 +141,20 @@ func run(args []string) error {
|
|||
scheduler.StartAsync()
|
||||
defer scheduler.Stop()
|
||||
|
||||
asyncMgr := async.New(async.Config{
|
||||
Workers: cfg.HTTP.AsyncWorkers,
|
||||
QueueSize: cfg.HTTP.AsyncQueueSize,
|
||||
ResultTTL: cfg.HTTP.AsyncResultTTL,
|
||||
}, mgr, elev, sink, log)
|
||||
defer asyncMgr.Close()
|
||||
|
||||
server, err := api.New(cfg.HTTP.Port, api.Deps{
|
||||
Manager: mgr,
|
||||
Elevation: elev,
|
||||
Metrics: sink,
|
||||
MetricsHandler: metricsHandler,
|
||||
MetricsPath: cfg.Metrics.Path,
|
||||
AsyncManager: asyncMgr,
|
||||
Log: log,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue