예제 #1
0
func waitForConnection(conn *grpc.ClientConn) error {
	state := conn.State()
	var err error

	if state != grpc.Ready {
		for {

			if !conn.WaitForStateChange(1*time.Second, conn.State()) {
				err = errors.New("connection")
			}

			state := conn.State()

			if state == grpc.Connecting || state == grpc.Idle {
				continue
			} else if state == grpc.TransientFailure {
				err = errors.New("fail")
			}

			break

		}
	}

	return err
}
예제 #2
0
func tearDown(s *grpc.Server, cc *grpc.ClientConn) {
	cc.Close()
	s.Stop()
}