Skip to content

Commit

Permalink
router: add RefreshBackend method for Router interface (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
better0332 authored May 23, 2023
1 parent 2f5bfd8 commit 74113ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/manager/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Router interface {
ConnEventReceiver

GetBackendSelector() BackendSelector
RefreshBackend()
RedirectConnections() error
ConnCount() int
// ServerVersion returns the TiDB version.
Expand Down
5 changes: 5 additions & 0 deletions pkg/manager/router/router_score.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ func (router *ScoreBasedRouter) adjustBackendList(be *glist.Element[*backendWrap
}
}

// RefreshBackend implements Router.GetBackendSelector interface.
func (router *ScoreBasedRouter) RefreshBackend() {
router.observer.Refresh()
}

// RedirectConnections implements Router.RedirectConnections interface.
// It redirects all connections compulsively. It's only used for testing.
func (router *ScoreBasedRouter) RedirectConnections() error {
Expand Down
2 changes: 2 additions & 0 deletions pkg/manager/router/router_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func (r *StaticRouter) GetBackendSelector() BackendSelector {
}
}

func (r *StaticRouter) RefreshBackend() {}

func (r *StaticRouter) RedirectConnections() error {
return nil
}
Expand Down

0 comments on commit 74113ab

Please sign in to comment.