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

Method WaitForConnectivityState

internal/testutils/balancer.go:257–270  ·  view source on GitHub ↗

WaitForConnectivityState waits until the state pushed to this ClientConn matches the wanted state. Returns an error if the provided context expires, including the last received state (if any).

(ctx context.Context, want connectivity.State)

Source from the content-addressed store, hash-verified

255// matches the wanted state. Returns an error if the provided context expires,
256// including the last received state (if any).
257func (tcc *BalancerClientConn) WaitForConnectivityState(ctx context.Context, want connectivity.State) error {
258 var lastState connectivity.State = -1
259 for {
260 select {
261 case <-ctx.Done():
262 return fmt.Errorf("timeout when waiting for state to be %s; last state: %s", want, lastState)
263 case s := <-tcc.NewStateCh:
264 if s == want {
265 return nil
266 }
267 lastState = s
268 }
269 }
270}
271
272// WaitForRoundRobinPicker waits for a picker that passes IsRoundRobin. Also
273// drains the matching state channel and requires it to be READY (if an entry

Calls 2

ErrorfMethod · 0.65
DoneMethod · 0.45