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

Function stayConnected

clientconn_test.go:1026–1042  ·  clientconn_test.go::stayConnected

stayConnected makes cc stay connected by repeatedly calling cc.Connect() until the state becomes Shutdown or until 10 seconds elapses.

(cc *ClientConn)

Source from the content-addressed store, hash-verified

1024// stayConnected makes cc stay connected by repeatedly calling cc.Connect()
1025// until the state becomes Shutdown or until 10 seconds elapses.
1026func stayConnected(cc *ClientConn) {
1027 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
1028 defer cancel()
1029
1030 for {
1031 state := cc.GetState()
1032 switch state {
1033 case connectivity.Idle:
1034 cc.Connect()
1035 case connectivity.Shutdown:
1036 return
1037 }
1038 if !cc.WaitForStateChange(ctx, state) {
1039 return
1040 }
1041 }
1042}
1043
1044func (s) TestURLAuthorityEscape(t *testing.T) {
1045 tests := []struct {

Calls 3

GetStateMethod · 0.65
ConnectMethod · 0.65
WaitForStateChangeMethod · 0.65

Tested by

no test coverage detected