// Ping returns a PingResult which indicates whether the registry is standalone or not.
175285
func (e *V1Endpoint) Ping() (PingResult, error) {
	logrus.Debugf("attempting v1 ping for registry endpoint %s", e)

	if e.String() == IndexServer {
		// Skip the check, we know this one is valid
		// (and we never want to fallback to http in case of error)
		return PingResult{Standalone: false}, nil
	}

	req, err := http.NewRequest("GET", e.Path("_ping"), nil)
	if err != nil {
		return PingResult{Standalone: false}, err
	}

	resp, err := e.client.Do(req)
	if err != nil {
		return PingResult{Standalone: false}, err
	}

	defer resp.Body.Close()

	jsonString, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return PingResult{Standalone: false}, fmt.Errorf("error while reading the http response: %s", err)
	}

	// If the header is absent, we assume true for compatibility with earlier
	// versions of the registry. default to true
	info := PingResult{
		Standalone: true,
	}
	if err := json.Unmarshal(jsonString, &info); err != nil {
		logrus.Debugf("Error unmarshaling the _ping PingResult: %s", err)
		// don't stop here. Just assume sane defaults
	}
	if hdr := resp.Header.Get("X-Docker-Registry-Version"); hdr != "" {
		logrus.Debugf("Registry version header: '%s'", hdr)
		info.Version = hdr
	}
	logrus.Debugf("PingResult.Version: %q", info.Version)

	standalone := resp.Header.Get("X-Docker-Registry-Standalone")
	logrus.Debugf("Registry standalone header: '%s'", standalone)
	// Accepted values are "true" (case-insensitive) and "1".
	if strings.EqualFold(standalone, "true") || standalone == "1" {
		info.Standalone = true
	} else if len(standalone) > 0 {
		// there is a header set, and it is not "true" or "1", so assume fails
		info.Standalone = false
	}
	logrus.Debugf("PingResult.Standalone: %t", info.Standalone)
	return info, nil
}
101567
func (r *ConsulAdapter) Ping() error {
	status := r.client.Status()
	leader, err := status.Leader()
	if err != nil {
		return err
	}
	log.Println("consul: current leader ", leader)

	return nil
}
682212
func (db *SQLDB) Ping() error {
	if err := db.DB.Ping(); err != nil {
		db.Log.Info("msg", "Error database not available", "err", err)
		return err
	}

	return nil
}
990263
func Ping(c *websocket.Conn) Websocket {
	p := &pingingWebsocket{conn: c}
	p.conn.SetPongHandler(p.pong)
	p.conn.SetReadDeadline(time.Now().Add(pongWait))
	p.pinger = time.AfterFunc(pingPeriod, p.ping)
	return p
}
13493
func Ping(s []string) *packet.Disconnect {
	return &packet.Disconnect{Reason: strings.Join(s, "\x00")}
}
1103148
func (e *EnvironProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	return nil
}
551545
func (c *Client) Ping() ([]byte, error) {
	opts := []byte{}

	response, err := c.ReqResp(opts, "RpbPingReq", true)
	if err != nil {
		return nil, err
	}

	return response.([]byte), nil
}
897383
func (s *RediStore) ping() (bool, error) {
	conn := s.Pool.Get()
	defer conn.Close()
	data, err := conn.Do("PING")
	if err != nil || data == nil {
		return false, err
	}
	return (data == "PONG"), nil
}
853512
func (p ManualProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	if p.ping != nil {
		return p.ping(endpoint)
	}
	return pingMachine(endpoint)
}
656046
func (c *asyncClient) Ping() (stat FutureBool, err Error) {
	resp, err := c.conn.QueueRequest(&PING, [][]byte{})
	if err == nil {
		stat = resp.future.(FutureBool)
	}

	return
}
314854
func (p *environProvider) Ping(callCtx callcontext.ProviderCallContext, endpoint string) error {
	// try to be smart and not punish people for adding or forgetting http
	u, err := url.Parse(endpoint)
	if err != nil {
		return errors.New("Invalid endpoint format, please give a full url or IP/hostname.")
	}
	switch u.Scheme {
	case "http", "https":
		// good!
	case "":
		u, err = url.Parse("https://" + endpoint + "/sdk")
		if err != nil {
			return errors.New("Invalid endpoint format, please give a full url or IP/hostname.")
		}
	default:
		return errors.New("Invalid endpoint format, please use an http or https URL.")
	}

	// Set a user, to force the dial function to perform a login. The login
	// should fail, since there's no password set.
	u.User = url.User("juju")

	ctx := context.Background()
	client, err := p.dial(ctx, u, "")
	if err != nil {
		if err.Error() == failedLoginMsg {
			// This is our expected error for trying to log into
			// vSphere without any creds, so return nil.
			return nil
		}
		logger.Errorf("Unexpected error dialing vSphere connection: %v", err)
		return errors.Errorf("No vCenter/ESXi available at %s", endpoint)
	}
	defer client.Close(ctx)

	// We shouldn't get here, since we haven't set a password, but it is
	// theoretically possible to have user="juju", password="".
	return nil
}
304404
func (p *Process) ping(addr string, timeout time.Duration) error {
	// Default to local process if addr not specified.
	if addr == "" {
		addr = fmt.Sprintf("localhost:%s", p.Port)
	}

	logger := p.Logger.New("fn", "ping", "addr", addr, "timeout", timeout)
	logger.Info("sending")

	timer := time.NewTimer(timeout)
	defer timer.Stop()

	ticker := time.NewTicker(checkInterval)
	defer ticker.Stop()

	for {
		// Attempt to ping the server.
		if ok := func() bool {
			logger.Info("sending PING")

			conn, err := redis.Dial("tcp", addr,
				redis.DialPassword(p.Password),
				redis.DialConnectTimeout(timeout),
				redis.DialReadTimeout(timeout),
				redis.DialWriteTimeout(timeout),
			)
			if err != nil {
				logger.Error("conn error", "err", err)
				return false
			}
			defer conn.Close()

			if _, err := conn.Do("PING"); err != nil {
				logger.Error("error getting upstream status", "err", err)
				return false
			}

			logger.Info("PONG received")
			return true
		}(); ok {
			return nil
		}

		select {
		case <-timer.C:
			logger.Info("timeout")
			return ErrTimeout
		case <-ticker.C:
		}
	}
}
85944
func (c *Client) Ping(ctx context.Context) error {
	pc := &http.Client{
		Transport: c.http.Transport,
		Timeout:   5 * time.Second,
	}
	resp, err := pc.Get("http://unix/ping")
	if err != nil {
		return err
	}
	_ = resp.Body.Close()
	return nil
}
1213879
func (s *SessionState) Ping(arg []byte, reply *[]byte) error {
	// For now we return nil. We can return an error if we are shutting
	// down or otherwise in a state we should signal poor health.
	// Reply should contain any context.
	s.ResetHeartbeat()
	s.logger.Debug("Ping received")
	*reply = []byte{}
	return nil
}
747154
func Ping(dstIP net.IP) (net.HardwareAddr, time.Duration, error) {
	if err := validateIP(dstIP); err != nil {
		return nil, 0, err
	}

	iface, err := findUsableInterfaceForNetwork(dstIP)
	if err != nil {
		return nil, 0, err
	}
	return PingOverIface(dstIP, *iface)
}
298286
func (c PubSubConn) Ping(data string) error {
	c.Conn.Send("PING", data)
	return c.Conn.Flush()
}
544069
func (db *DB) Ping() error {
	// TODO(bradfitz): give drivers an optional hook to implement
	// this in a more efficient or more reliable way, if they
	// have one.
	dc, err := db.conn()
	if err != nil {
		return err
	}
	db.putConn(dc, nil)
	return nil
}