Skip to content

Commit aafbd20

Browse files
committed
Remove function UnrouteRoutes
1 parent b72ae61 commit aafbd20

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

router/poolmgr/pool_mgr.go

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ func (s *SessConnManager) UnRouteWithError(client client.RouterClient, sh []kr.S
128128

129129
// TODO : unit tests
130130
func (s *SessConnManager) UnRouteCB(cl client.RouterClient, sh []kr.ShardKey) error {
131+
132+
if cl.Server() == nil {
133+
/* If there is nothing to unroute, return */
134+
return nil
135+
}
136+
131137
for _, shkey := range sh {
132138
if err := cl.Server().UnRouteShard(shkey, cl.Rule()); err != nil {
133139
return err

router/relay/relay.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,10 @@ func (rst *RelayStateImpl) RerouteToTargetRoute(route *kr.ShardKey) error {
659659
}
660660

661661
// TODO : unit tests
662-
func (rst *RelayStateImpl) CurrentRoutes() []*kr.ShardKey {
662+
func (rst *RelayStateImpl) CurrentRoutes() []kr.ShardKey {
663663
switch q := rst.routingState.(type) {
664664
case plan.ShardMatchState:
665-
return []*kr.ShardKey{q.Route}
665+
return []kr.ShardKey{*q.Route}
666666
default:
667667
return nil
668668
}
@@ -1064,7 +1064,7 @@ func (rst *RelayStateImpl) ProcessExtendedBuffer() error {
10641064
if rst.bindRoute == nil {
10651065
routes := rst.CurrentRoutes()
10661066
if len(routes) == 1 {
1067-
rst.bindRoute = routes[0]
1067+
rst.bindRoute = &routes[0]
10681068
} else {
10691069
return fmt.Errorf("failed to deploy prepared statement")
10701070
}
@@ -1440,7 +1440,7 @@ func (rst *RelayStateImpl) PrepareRelayStepOnAnyRoute() (func() error, error) {
14401440
case nil:
14411441
routes := rst.CurrentRoutes()
14421442
return func() error {
1443-
return rst.UnrouteRoutes(routes)
1443+
return rst.Unroute(routes)
14441444
}, nil
14451445
case ErrSkipQuery:
14461446
if err := rst.Client().ReplyErr(err); err != nil {

router/route/routemgr.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ type RouteMgr interface {
1313
RerouteToRandomRoute() error
1414
RerouteToTargetRoute(route *kr.ShardKey) error
1515

16-
CurrentRoutes() []*kr.ShardKey
16+
CurrentRoutes() []kr.ShardKey
1717
/* Unroute Routines */
1818
UnRouteWithError(shkey []kr.ShardKey, errmsg error) error
1919
Unroute(shkey []kr.ShardKey) error
20-
UnrouteRoutes(routes []*kr.ShardKey) error
2120
}

0 commit comments

Comments
 (0)