Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router: add RefreshBackend method for Router interface #287

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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