Skip to content

Commit

Permalink
Vtgateproxy firstready balancer fail fast (#362)
Browse files Browse the repository at this point in the history
* return a custom error to fail fast

* fatal if the resolver cannot initialize
  • Loading branch information
demmer committed May 21, 2024
1 parent 91cc200 commit 3dee7ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion go/vt/vtgateproxy/firstready_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ limitations under the License.
// https://github.com/grpc/grpc-go/blob/master/pickfirst.go

import (
"errors"
"sync"

"google.golang.org/grpc/balancer"
Expand Down Expand Up @@ -60,7 +61,7 @@ func (f *frPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker {
log.V(100).Infof("first_ready: Build called with info: %v", info)

if len(info.ReadySCs) == 0 {
return base.NewErrPicker(balancer.ErrNoSubConnAvailable)
return base.NewErrPicker(errors.New("no available connections"))
}

f.mu.Lock()
Expand Down
6 changes: 5 additions & 1 deletion go/vt/vtgateproxy/vtgateproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,16 @@ func Init() {
return append(opts, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, *balancerType))), nil
})

RegisterJSONGateResolver(
_, err := RegisterJSONGateResolver(
*vtgateHostsFile,
*addressField,
*portField,
*poolTypeField,
*affinityField,
*affinityValue,
)

if err != nil {
log.Fatalf("error initializing resolver: %v", err)
}
}

0 comments on commit 3dee7ad

Please sign in to comment.