regeneratePicker takes a snapshot of the balancer, and generates a picker from it. The picker is - errPicker if the balancer is in TransientFailure, - built by the pickerBuilder with all READY SubConns otherwise.
()
| 163 | // - errPicker if the balancer is in TransientFailure, |
| 164 | // - built by the pickerBuilder with all READY SubConns otherwise. |
| 165 | func (b *baseBalancer) regeneratePicker() { |
| 166 | if b.state == connectivity.TransientFailure { |
| 167 | b.picker = NewErrPicker(b.mergeErrors()) |
| 168 | return |
| 169 | } |
| 170 | readySCs := make(map[balancer.SubConn]SubConnInfo) |
| 171 | |
| 172 | // Filter out all ready SCs from full subConn map. |
| 173 | for addr, sc := range b.subConns.All() { |
| 174 | if st, ok := b.scStates[sc]; ok && st == connectivity.Ready { |
| 175 | readySCs[sc] = SubConnInfo{Address: addr} |
| 176 | } |
| 177 | } |
| 178 | b.picker = b.pickerBuilder.Build(PickerBuildInfo{ReadySCs: readySCs}) |
| 179 | } |
| 180 | |
| 181 | // UpdateSubConnState is a nop because a StateListener is always set in NewSubConn. |
| 182 | func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { |
no test coverage detected