engine refactor
This commit is contained in:
parent
9e663db9dc
commit
81b8e763bd
37 changed files with 3532 additions and 1639 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
|
||||
"predictor-refactored/internal/api/admin"
|
||||
"predictor-refactored/internal/api/async"
|
||||
"predictor-refactored/internal/api/middleware"
|
||||
"predictor-refactored/internal/api/tawhiri"
|
||||
v2 "predictor-refactored/internal/api/v2"
|
||||
|
|
@ -33,12 +34,13 @@ type Server struct {
|
|||
|
||||
// Deps are the runtime dependencies the API layer needs.
|
||||
type Deps struct {
|
||||
Manager *datasets.Manager
|
||||
Elevation *elevation.Dataset
|
||||
Metrics metrics.Sink
|
||||
Manager *datasets.Manager
|
||||
Elevation *elevation.Dataset
|
||||
Metrics metrics.Sink
|
||||
MetricsHandler http.Handler // optional; mounted at MetricsPath when non-nil
|
||||
MetricsPath string
|
||||
Log *zap.Logger
|
||||
AsyncManager *async.Manager // optional; mounts /api/v1/predictions when non-nil
|
||||
Log *zap.Logger
|
||||
}
|
||||
|
||||
// New wires the HTTP server. The returned Server is not yet started.
|
||||
|
|
@ -68,6 +70,12 @@ func New(port int, d Deps) (*Server, error) {
|
|||
adminH := admin.New(d.Manager, d.Log)
|
||||
adminH.Register(mux)
|
||||
|
||||
// Async prediction endpoints (optional).
|
||||
if d.AsyncManager != nil {
|
||||
asyncH := async.NewHandler(d.AsyncManager)
|
||||
asyncH.Register(mux)
|
||||
}
|
||||
|
||||
// Metrics endpoint.
|
||||
if d.MetricsHandler != nil && d.MetricsPath != "" {
|
||||
mux.Handle(d.MetricsPath, d.MetricsHandler)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue