Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: yisaer <[email protected]>
  • Loading branch information
Yisaer committed Nov 1, 2021
1 parent f9f2aa1 commit 116501c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions server/plan_replayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ import (

// PlanReplayerHandler is the handler for dumping plan replayer file.
type PlanReplayerHandler struct {
infoSyncer *infosync.InfoSyncer
infoGetter *infosync.InfoSyncer
address string
statusPort uint
}

func (s *Server) newPlanReplayerHandler() *PlanReplayerHandler {
cfg := config.GetGlobalConfig()
return &PlanReplayerHandler{
infoSyncer: s.dom.InfoSyncer(),
prh := &PlanReplayerHandler{
address: cfg.AdvertiseAddress,
statusPort: cfg.Status.StatusPort,
}
if s.dom != nil && s.dom.InfoSyncer() != nil {
prh.infoGetter = s.dom.InfoSyncer()
}
return prh
}

func (prh PlanReplayerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -77,14 +80,18 @@ func (prh PlanReplayerHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
w.WriteHeader(http.StatusOK)
return
}
if prh.infoGetter == nil {
w.WriteHeader(http.StatusNotFound)
return
}
// we didn't find file for forward request, return 404
forwarded := req.URL.Query().Get("forward")
if len(forwarded) > 0 {
w.WriteHeader(http.StatusNotFound)
return
}
// If we didn't find file in origin request, try to broadcast the request to all remote tidb-servers
topos, err := prh.infoSyncer.GetAllTiDBTopology(req.Context())
topos, err := prh.infoGetter.GetAllTiDBTopology(req.Context())
if err != nil {
writeError(w, err)
return
Expand Down

0 comments on commit 116501c

Please sign in to comment.