Skip to content

Commit

Permalink
support batch
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Sep 7, 2023
1 parent 74ead5c commit c9ca0ae
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/api/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"

"github.com/gorilla/mux"
"github.com/pingcap/errors"
Expand Down Expand Up @@ -441,6 +442,20 @@ func (h *ruleHandler) GetPlacementRules(w http.ResponseWriter, r *http.Request)
h.rd.JSON(w, http.StatusPreconditionFailed, errPlacementDisabled.Error())
return
}

if groupsStr := r.URL.Query().Get("groups"); len(groupsStr) > 0 {
var bundles []placement.GroupBundle
groupIDs := strings.Split(groupsStr, ",")
for _, g := range groupIDs {
bundle := cluster.GetRuleManager().GetGroupBundle(g)
if bundle.Rules != nil {
bundles = append(bundles, bundle)
}
}
h.rd.JSON(w, http.StatusOK, bundles)
return
}

bundles := cluster.GetRuleManager().GetAllGroupBundles()
h.rd.JSON(w, http.StatusOK, bundles)
}
Expand Down

0 comments on commit c9ca0ae

Please sign in to comment.