Reduce server console polling load
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user