Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp committed Jan 22, 2024
1 parent fb6606a commit f7ef6a9
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 142 deletions.
16 changes: 0 additions & 16 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"io"
"net/http"
"os"
"time"

"github.com/pingcap/errors"
Expand Down Expand Up @@ -270,21 +269,6 @@ func WithMetrics(
}
}

// WithLoggerRedirection configures the client with the given logger redirection.
func WithLoggerRedirection(logLevel, fileName string) ClientOption {
cfg := &log.Config{}
cfg.Level = logLevel
if fileName != "" {
f, _ := os.CreateTemp(".", fileName)
fname := f.Name()
f.Close()
cfg.File.Filename = fname
}
lg, p, _ := log.InitLogger(cfg)
log.ReplaceGlobals(lg, p)
return func(c *client) {}
}

// NewClientWithServiceDiscovery creates a PD HTTP client with the given PD service discovery.
func NewClientWithServiceDiscovery(
source string,
Expand Down
7 changes: 6 additions & 1 deletion client/pd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ func NewDefaultPDServiceDiscovery(
option: newOption(),
}
pdsd.urls.Store(urls)
if err := pdsd.Init(); err != nil {
return nil
}
return pdsd
}

Expand Down Expand Up @@ -911,7 +914,9 @@ func (c *pdServiceDiscovery) checkServiceModeChanged() error {
if clusterInfo == nil || len(clusterInfo.ServiceModes) == 0 {
return errors.WithStack(errNoServiceModeReturned)
}
c.serviceModeUpdateCb(clusterInfo.ServiceModes[0])
if c.serviceModeUpdateCb != nil {
c.serviceModeUpdateCb(clusterInfo.ServiceModes[0])
}
return nil
}

Expand Down
Loading

0 comments on commit f7ef6a9

Please sign in to comment.