Skip to content

Commit

Permalink
one more refactor to align more with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
demmer committed Jul 8, 2024
1 parent 157b40f commit fe2520d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions go/vt/vtgate/tabletgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,12 @@ func init() {
})
}

func useBalancer(keyspace string) bool {
if balancerEnabled {
if len(balancerKeyspaces) == 0 {
// this utility can be replaced with slices.Contains in a future iteration
func isBalancerKeyspaceEnabled(keyspace string) bool {
for _, k := range balancerKeyspaces {
if keyspace == k {
return true
}

for _, k := range balancerKeyspaces {
if keyspace == k {
return true
}
}
}

return false
Expand Down Expand Up @@ -373,7 +368,12 @@ func (gw *TabletGateway) withRetry(ctx context.Context, target *querypb.Target,
}

var th *discovery.TabletHealth
if useBalancer(target.Keyspace) {

useBalancer := balancerEnabled
if balancerEnabled && len(balancerKeyspaces) > 0 {
useBalancer = isBalancerKeyspaceEnabled(target.Keyspace)
}
if useBalancer {
// filter out the tablets that we've tried before (if any), then pick the best one
if len(invalidTablets) > 0 {
validTablets := make([]*discovery.TabletHealth, len(tablets))
Expand Down

0 comments on commit fe2520d

Please sign in to comment.