Reduce server console polling load

This commit is contained in:
npc0-hue
2026-09-07 19:49:20 +08:00
parent 1b583f3ca6
commit 4ab7bb820d
10 changed files with 110 additions and 25 deletions
+15
View File
@@ -2441,6 +2441,7 @@ func (h *coreHandlers) jobs(w http.ResponseWriter, r *http.Request) {
ServerInstanceID: r.URL.Query().Get("serverInstanceId"),
RunEndpointID: r.URL.Query().Get("runEndpointId"),
State: domain.JobState(r.URL.Query().Get("state")),
States: parseJobStates(r.URL.Query().Get("states")),
}
var jobs []domain.Job
var err error
@@ -2471,6 +2472,20 @@ func (h *coreHandlers) jobs(w http.ResponseWriter, r *http.Request) {
}
}
func parseJobStates(raw string) []domain.JobState {
if strings.TrimSpace(raw) == "" {
return nil
}
states := []domain.JobState{}
for _, part := range strings.Split(raw, ",") {
state := domain.JobState(strings.TrimSpace(part))
if state != "" {
states = append(states, state)
}
}
return states
}
// jobCancel godoc
// @Summary Request job cancellation
// @Description Records a cancellation request for an accepted or running job; run observes it through the job cancel poll route.