chore(iot): MaxReconnectInterval 30с + Debug для health-проб и телеметрии (ревью)
- bridge: SetMaxReconnectInterval(30с) — дефолт ~10м слишком долог для телеметрии. - logging middleware: /health,/healthz,/ready → Debug (не засорять лог). - processor: 'telemetry buffered' вместо Info 'saved' (данные ещё буферизованы).
This commit is contained in:
@@ -24,7 +24,14 @@ func Logging(log *slog.Logger, next http.Handler) http.Handler {
|
||||
start := time.Now()
|
||||
rw := &responseWriter{ResponseWriter: w, status: http.StatusOK}
|
||||
next.ServeHTTP(rw, r)
|
||||
log.Info("http",
|
||||
// Пробы здоровья логируем на Debug: платформа опрашивает их часто, а
|
||||
// Info-строка на каждую засоряет лог (ревью 2026-10-10).
|
||||
level := slog.LevelInfo
|
||||
switch r.URL.Path {
|
||||
case "/health", "/healthz", "/ready":
|
||||
level = slog.LevelDebug
|
||||
}
|
||||
log.Log(r.Context(), level, "http",
|
||||
"method", r.Method,
|
||||
"path", r.URL.Path,
|
||||
"status", rw.status,
|
||||
|
||||
@@ -89,6 +89,9 @@ func connectMQTT(ctx context.Context, cfg *config.Config, log *slog.Logger, hand
|
||||
opts.SetAutoReconnect(true)
|
||||
opts.SetConnectRetry(true)
|
||||
opts.SetConnectRetryInterval(5 * time.Second)
|
||||
// MaxReconnectInterval по умолчанию ~10 минут — слишком долго для потоковой
|
||||
// телеметрии; 30с (ревью 2026-10-10).
|
||||
opts.SetMaxReconnectInterval(30 * time.Second)
|
||||
opts.SetKeepAlive(30 * time.Second)
|
||||
opts.SetCleanSession(false)
|
||||
|
||||
|
||||
@@ -56,7 +56,9 @@ func processTelemetry(ctx context.Context, body string, store *iotpg.IoTPostgres
|
||||
return err
|
||||
}
|
||||
|
||||
log.Info("consumer: telemetry saved",
|
||||
// Debug: данные ещё только буферизованы (не записаны), Info на каждое
|
||||
// сообщение засорял бы лог (ревью 2026-10-10).
|
||||
log.Debug("consumer: telemetry buffered",
|
||||
"namespace", envelope.Namespace,
|
||||
"device", envelope.DeviceID,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user