Skip to content

Commit

Permalink
fix orca OOB test to use RegisterOOBListener correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Sep 24, 2024
1 parent 2eb9103 commit 230f34d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions interop/orcalb.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ func (orcabb) Name() string {
}

type orcab struct {
cc balancer.ClientConn
sc balancer.SubConn
cancelWatch func()
cc balancer.ClientConn
sc balancer.SubConn

reportMu sync.Mutex
report *v3orcapb.OrcaLoadReport
Expand All @@ -70,7 +69,6 @@ func (o *orcab) UpdateClientConnState(s balancer.ClientConnState) error {
o.cc.UpdateState(balancer.State{ConnectivityState: connectivity.TransientFailure, Picker: base.NewErrPicker(fmt.Errorf("error creating subconn: %v", err))})
return nil
}
o.cancelWatch = orca.RegisterOOBListener(o.sc, o, orca.OOBListenerOptions{ReportInterval: time.Second})
o.sc.Connect()
o.cc.UpdateState(balancer.State{ConnectivityState: connectivity.Connecting, Picker: base.NewErrPicker(balancer.ErrNoSubConnAvailable)})
return nil
Expand All @@ -89,6 +87,7 @@ func (o *orcab) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnSt
func (o *orcab) updateSubConnState(state balancer.SubConnState) {
switch state.ConnectivityState {
case connectivity.Ready:
orca.RegisterOOBListener(o.sc, o, orca.OOBListenerOptions{ReportInterval: time.Second})
o.cc.UpdateState(balancer.State{ConnectivityState: connectivity.Ready, Picker: &orcaPicker{o: o}})
case connectivity.TransientFailure:
o.cc.UpdateState(balancer.State{ConnectivityState: connectivity.TransientFailure, Picker: base.NewErrPicker(fmt.Errorf("all subchannels in transient failure: %v", state.ConnectionError))})
Expand All @@ -102,9 +101,7 @@ func (o *orcab) updateSubConnState(state balancer.SubConnState) {
}
}

func (o *orcab) Close() {
o.cancelWatch()
}
func (o *orcab) Close() {}

func (o *orcab) OnLoadReport(r *v3orcapb.OrcaLoadReport) {
o.reportMu.Lock()
Expand Down

0 comments on commit 230f34d

Please sign in to comment.