Skip to content

Commit

Permalink
all: replace remaining UpdateSubConnState usages with StateListener
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Aug 4, 2023
1 parent e9a4e94 commit c51f67c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/features/orca/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ func (o *orcaLB) UpdateClientConnState(ccs balancer.ClientConnState) error {
}

// Create one SubConn for the address and connect it.
sc, err := o.cc.NewSubConn(addrs, balancer.NewSubConnOptions{})
var sc balancer.SubConn
sc, err := o.cc.NewSubConn(addrs, balancer.NewSubConnOptions{
StateListener: func(scs balancer.SubConnState) {
if scs.ConnectivityState == connectivity.Ready {
o.cc.UpdateState(balancer.State{ConnectivityState: connectivity.Ready, Picker: &picker{sc}})
}
},
})
if err != nil {
return fmt.Errorf("orcaLB: error creating SubConn: %v", err)
}
Expand All @@ -123,11 +130,8 @@ func (o *orcaLB) UpdateClientConnState(ccs balancer.ClientConnState) error {

func (o *orcaLB) ResolverError(error) {}

func (o *orcaLB) UpdateSubConnState(sc balancer.SubConn, scs balancer.SubConnState) {
if scs.ConnectivityState == connectivity.Ready {
o.cc.UpdateState(balancer.State{ConnectivityState: connectivity.Ready, Picker: &picker{sc}})
}
}
// TODO: unused; remove when no longer required.
func (o *orcaLB) UpdateSubConnState(sc balancer.SubConn, scs balancer.SubConnState) {}

func (o *orcaLB) Close() {}

Expand Down

0 comments on commit c51f67c

Please sign in to comment.