Skip to content

Commit

Permalink
Route retry (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored Dec 16, 2022
1 parent a27ec65 commit e0ec1ae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/proxy/backend/backend_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,19 @@ func NewBackendConnManager(logger *zap.Logger, handshakeHandler HandshakeHandler
redirectResCh: make(chan *redirectResult, 1),
}
mgr.getBackendIO = func(ctx ConnContext, auth *Authenticator, resp *pnet.HandshakeResp) (*pnet.PacketIO, error) {
router, err := handshakeHandler.GetRouter(ctx, resp)
r, err := handshakeHandler.GetRouter(ctx, resp)
if err != nil {
return nil, err
}
addr, err := router.Route(mgr)
// wait for initialize
var addr string
for start := time.Now(); time.Since(start) < time.Second*5; {
addr, err = r.Route(mgr)
if !errors.Is(err, router.ErrNoInstanceToSelect) {
break
}
time.Sleep(time.Millisecond * 200)
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e0ec1ae

Please sign in to comment.