Hardcode agent stale timeout
This commit is contained in:
@@ -22,8 +22,7 @@ func handleUpdateConfig(stores Stores, broker *events.Broker) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// Decode partial patch
|
||||
var patch struct {
|
||||
DefaultWaitSeconds *int `json:"default_wait_seconds"`
|
||||
AgentStaleAfterSeconds *int `json:"agent_stale_after_seconds"`
|
||||
DefaultWaitSeconds *int `json:"default_wait_seconds"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&patch); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "Invalid JSON")
|
||||
@@ -41,9 +40,6 @@ func handleUpdateConfig(stores Stores, broker *events.Broker) http.HandlerFunc {
|
||||
if patch.DefaultWaitSeconds != nil {
|
||||
current.DefaultWaitSeconds = *patch.DefaultWaitSeconds
|
||||
}
|
||||
if patch.AgentStaleAfterSeconds != nil {
|
||||
current.AgentStaleAfterSeconds = *patch.AgentStaleAfterSeconds
|
||||
}
|
||||
|
||||
if err := stores.Settings.Update(current); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
|
||||
@@ -45,7 +45,7 @@ func handleStatus(stores Stores) http.HandlerFunc {
|
||||
}
|
||||
|
||||
if latest != nil {
|
||||
connected := time.Since(latest.LastSeenAt).Seconds() <= float64(cfg.AgentStaleAfterSeconds)
|
||||
connected := time.Since(latest.LastSeenAt).Seconds() <= float64(config.AgentStaleAfterSeconds)
|
||||
agent = map[string]any{
|
||||
"connected": connected,
|
||||
"last_seen_at": latest.LastSeenAt.Format(time.RFC3339Nano),
|
||||
@@ -69,7 +69,6 @@ func handleStatus(stores Stores) http.HandlerFunc {
|
||||
"settings": models.Settings{
|
||||
DefaultWaitSeconds: cfg.DefaultWaitSeconds,
|
||||
DefaultEmptyResponse: cfg.DefaultEmptyResponse,
|
||||
AgentStaleAfterSeconds: cfg.AgentStaleAfterSeconds,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user