MCPcopy
hub / github.com/vulcand/vulcand / getTopServers

Method getTopServers

api/api.go:229–251  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, params map[string]string, body []byte)

Source from the content-addressed store, hash-verified

227}
228
229func (c *ProxyController) getTopServers(w http.ResponseWriter, r *http.Request, params map[string]string, body []byte) (interface{}, error) {
230 limit, err := strconv.Atoi(formGet(r.Form, "limit", "0"))
231 if err != nil {
232 return nil, err
233 }
234 var bk *engine.BackendKey
235 if key := r.Form.Get("backendId"); key != "" {
236 bk = &engine.BackendKey{Id: key}
237 }
238 servers, err := c.stats.TopServers(bk)
239 if err != nil {
240 return nil, err
241 }
242 if bk != nil {
243 anomaly.MarkServerAnomalies(servers)
244 }
245 if limit > 0 && limit < len(servers) {
246 servers = servers[:limit]
247 }
248 return Response{
249 "Servers": servers,
250 }, nil
251}
252
253func (c *ProxyController) getBackend(w http.ResponseWriter, r *http.Request, params map[string]string, body []byte) (interface{}, error) {
254 return formatResult(c.ng.GetBackend(engine.BackendKey{Id: params["id"]}))

Callers

nothing calls this directly

Calls 4

MarkServerAnomaliesFunction · 0.92
formGetFunction · 0.85
TopServersMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected