0.2.79 - Slow api fixes
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"math"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -124,6 +125,19 @@ func (s *Server) radarrAlertWindow() time.Duration {
|
||||
s.cfg.RadarrAlertWindow)
|
||||
}
|
||||
|
||||
// slowRequestThreshold is the line between a request that logs a breakdown and one that
|
||||
// does not. Switched off it returns a duration no request can exceed rather than zero,
|
||||
// because zero would mean *every* request carried one — the opposite of what the operator
|
||||
// asked for.
|
||||
func (s *Server) slowRequestThreshold() time.Duration {
|
||||
threshold := overrideWindow(s.gatewaySettings.get().SlowRequestMillis, time.Millisecond,
|
||||
s.cfg.SlowRequestThreshold)
|
||||
if threshold <= 0 {
|
||||
return math.MaxInt64
|
||||
}
|
||||
return threshold
|
||||
}
|
||||
|
||||
func (s *Server) embyHealthInterval() time.Duration {
|
||||
return overrideWindow(s.gatewaySettings.get().EmbyHealthSeconds, time.Second,
|
||||
s.cfg.EmbyHealthInterval)
|
||||
@@ -162,6 +176,7 @@ type deployedGatewaySettings struct {
|
||||
SonarrAlertMinutes int `json:"sonarrAlertMinutes"`
|
||||
RadarrAlertMinutes int `json:"radarrAlertMinutes"`
|
||||
EmbyHealthSeconds int `json:"embyHealthSeconds"`
|
||||
SlowRequestMillis int `json:"slowRequestMillis"`
|
||||
LibrarySyncMinutes int `json:"librarySyncMinutes"`
|
||||
}
|
||||
|
||||
@@ -177,6 +192,7 @@ func (s *Server) deployedSettings() deployedGatewaySettings {
|
||||
SonarrAlertMinutes: int(s.cfg.SonarrAlertWindow / time.Minute),
|
||||
RadarrAlertMinutes: int(s.cfg.RadarrAlertWindow / time.Minute),
|
||||
EmbyHealthSeconds: int(s.cfg.EmbyHealthInterval / time.Second),
|
||||
SlowRequestMillis: int(s.cfg.SlowRequestThreshold / time.Millisecond),
|
||||
LibrarySyncMinutes: int(s.cfg.SyncInterval / time.Minute),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user