(params martini.Params)
| 354 | } |
| 355 | |
| 356 | func (s *apiServer) GroupAddServer(params martini.Params) (int, string) { |
| 357 | if err := s.verifyXAuth(params); err != nil { |
| 358 | return rpc.ApiResponseError(err) |
| 359 | } |
| 360 | gid, err := s.parseInteger(params, "gid") |
| 361 | if err != nil { |
| 362 | return rpc.ApiResponseError(err) |
| 363 | } |
| 364 | addr, err := s.parseAddr(params) |
| 365 | if err != nil { |
| 366 | return rpc.ApiResponseError(err) |
| 367 | } |
| 368 | dc := params["datacenter"] |
| 369 | c, err := redis.NewClient(addr, s.topom.Config().ProductAuth, time.Second) |
| 370 | if err != nil { |
| 371 | log.WarnErrorf(err, "create redis client to %s failed", addr) |
| 372 | return rpc.ApiResponseError(err) |
| 373 | } |
| 374 | defer c.Close() |
| 375 | if _, err := c.SlotsInfo(); err != nil { |
| 376 | log.WarnErrorf(err, "redis %s check slots-info failed", addr) |
| 377 | return rpc.ApiResponseError(err) |
| 378 | } |
| 379 | if err := s.topom.GroupAddServer(gid, dc, addr); err != nil { |
| 380 | return rpc.ApiResponseError(err) |
| 381 | } else { |
| 382 | return rpc.ApiResponseJson("OK") |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | func (s *apiServer) GroupDelServer(params martini.Params) (int, string) { |
| 387 | if err := s.verifyXAuth(params); err != nil { |
nothing calls this directly
no test coverage detected