MCPcopy
hub / github.com/grpc/grpc-go / regeneratePicker

Method regeneratePicker

balancer/base/balancer.go:165–179  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

163// - errPicker if the balancer is in TransientFailure,
164// - built by the pickerBuilder with all READY SubConns otherwise.
165func (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.
182func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {

Callers 3

ResolverErrorMethod · 0.95
UpdateClientConnStateMethod · 0.95
updateSubConnStateMethod · 0.95

Calls 4

mergeErrorsMethod · 0.95
NewErrPickerFunction · 0.85
BuildMethod · 0.65
AllMethod · 0.45

Tested by

no test coverage detected