(sc balancer.SubConn, state balancer.SubConnState)
| 132 | } |
| 133 | |
| 134 | func (b *orcab) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { |
| 135 | b.mu.Lock() |
| 136 | if b.stopOOBListeners == nil { |
| 137 | b.mu.Unlock() |
| 138 | return |
| 139 | } |
| 140 | |
| 141 | if state.ConnectivityState == connectivity.Ready { |
| 142 | oldStop := b.stopOOBListeners[sc] |
| 143 | if oldStop != nil { |
| 144 | oldStop() |
| 145 | } |
| 146 | stop := orca.RegisterOOBListener(sc, &orcaOOBListener{subConn: sc, balancer: b}, orca.OOBListenerOptions{ReportInterval: time.Second}) |
| 147 | b.stopOOBListeners[sc] = stop |
| 148 | b.mu.Unlock() |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | stop := b.stopOOBListeners[sc] |
| 153 | if stop != nil { |
| 154 | delete(b.stopOOBListeners, sc) |
| 155 | defer func() { stop() }() |
| 156 | } |
| 157 | b.mu.Unlock() |
| 158 | |
| 159 | if state.ConnectivityState == connectivity.Shutdown { |
| 160 | b.oobState.mu.Lock() |
| 161 | delete(b.oobState.reports, sc) |
| 162 | b.oobState.mu.Unlock() |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // UpdateState intercepts state updates from endpointsharding to wrap the |
| 167 | // picker with ORCA load report handling. |
no test coverage detected