feat(go): add post raw frame query
This commit is contained in:
@@ -135,7 +135,9 @@ func main() {
|
||||
healthChecks = append(healthChecks, health.Check{Name: "tdengine", Check: db.PingContext})
|
||||
closeHistory = func() { _ = db.Close() }
|
||||
database := env("TDENGINE_DATABASE", history.DefaultDatabase)
|
||||
mux.Handle("/api/history/raw-frames", history.NewRawFrameHandler(history.NewRawFrameRepository(db, database)))
|
||||
rawFrameHandler := history.NewRawFrameHandler(history.NewRawFrameRepository(db, database))
|
||||
mux.Handle("/api/history/raw-frames", rawFrameHandler)
|
||||
mux.Handle("/api/history/raw-frames/query", rawFrameHandler)
|
||||
mux.Handle("/api/history/locations", history.NewLocationHandler(history.NewLocationRepository(db, database)))
|
||||
logger.Info("history query enabled", "driver", driver, "database", database)
|
||||
} else {
|
||||
@@ -145,6 +147,7 @@ func main() {
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{"error": "TDENGINE_DSN is not configured"})
|
||||
}
|
||||
mux.HandleFunc("/api/history/raw-frames", historyUnavailable)
|
||||
mux.HandleFunc("/api/history/raw-frames/query", historyUnavailable)
|
||||
mux.HandleFunc("/api/history/locations", historyUnavailable)
|
||||
logger.Warn("TDENGINE_DSN is empty; history query api disabled")
|
||||
}
|
||||
|
||||
@@ -164,6 +164,16 @@ func TestRealtimeAPICachesBindingPlateResolver(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealtimeAPIExposesPostRawFrameQueryRoute(t *testing.T) {
|
||||
source, err := os.ReadFile("main.go")
|
||||
if err != nil {
|
||||
t.Fatalf("read main.go: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(source), `"/api/history/raw-frames/query"`) {
|
||||
t.Fatalf("realtime api should expose POST raw frame query route")
|
||||
}
|
||||
}
|
||||
|
||||
type contextCheckingRealtimeUpdater struct {
|
||||
ctxErr error
|
||||
count int
|
||||
|
||||
Reference in New Issue
Block a user