feat(platform): query tdengine history data

This commit is contained in:
lingniu
2026-07-03 21:22:21 +08:00
parent 2de569f104
commit f9b8182949
11 changed files with 306 additions and 55 deletions

View File

@@ -2,6 +2,7 @@ package app
import (
"context"
"database/sql"
"log"
"net/http"
"time"
@@ -16,11 +17,20 @@ func NewServer(cfg config.Config) http.Handler {
if cfg.MySQLDSN != "" {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
db, err := platform.OpenMySQL(ctx, cfg.MySQLDSN)
db, err := platform.OpenSQL(ctx, "mysql", cfg.MySQLDSN)
if err != nil {
log.Printf("production mysql store disabled: %v", err)
} else {
store = platform.NewProductionStore(db, cfg.TDengineDatabase)
var tdengine *sql.DB
if cfg.TDengineDSN != "" {
tdengine, err = platform.OpenSQL(ctx, cfg.TDengineDriver, cfg.TDengineDSN)
if err != nil {
log.Printf("production tdengine store disabled: %v", err)
} else {
log.Printf("production tdengine store enabled")
}
}
store = platform.NewProductionStore(db, tdengine, cfg.TDengineDatabase)
log.Printf("production mysql store enabled")
}
}