// Ping will configure libp2p to support the ping service; enable by default.
168746
func Ping(enable bool) Option {
	return func(cfg *Config) error {
		cfg.DisablePing = !enable
		return nil
	}
}
1323227
func (p *Pool) Ping() error {
	_, pc, err := p.conn()
	if err != nil {
		return err
	}
	return pc.Close()
}
1067493
func (engine *Engine) Ping() error {
	session := engine.NewSession()
	defer session.Close()
	engine.logger.Infof("PING DATABASE %v", engine.DriverName())
	return session.Ping()
}
859120
func (p EnvironProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	c := p.ClientFromEndpoint(endpoint)
	if _, err := c.IdentityAuthOptions(); err != nil {
		common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
		return errors.Wrap(err, errors.Errorf("No Openstack server running at %s", endpoint))
	}
	return nil
}
562799
func (c *Conn) Ping() error {
	// This is a new command, need to reset the sequence.
	c.sequence = 0

	if err := c.writePacket([]byte{ComPing}); err != nil {
		return NewSQLError(CRServerGone, SSUnknownSQLState, "%v", err)
	}
	data, err := c.readEphemeralPacket()
	if err != nil {
		return NewSQLError(CRServerLost, SSUnknownSQLState, "%v", err)
	}
	defer c.recycleReadPacket()
	switch data[0] {
	case OKPacket:
		return nil
	case ErrPacket:
		return ParseErrorPacket(data)
	}
	return vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected packet type: %d", data[0])
}
716737
func (api *API) Ping() ([]string, error) {
	url := createUrl(api, pingPathSegment)
	result := []string{}
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}

	return result, nil
}
699770
func (ctlr *Controller) Ping() error {
	if ctlr.pool.SystemState() == nil {
		return errors.New("pool is closed")
	}
	return ctlr.pool.SystemState().Ping()
}
601982
func (l *ListenerConn) Ping() error {
	sent, err := l.ExecSimpleQuery("")
	if !sent {
		return err
	}
	if err != nil {
		// shouldn't happen
		panic(err)
	}
	return nil
}
587537
func (c *Clamd) Ping() error {
	ch, err := c.simpleCommand("PING")
	if err != nil {
		return err
	}

	select {
	case s := (<-ch):
		switch s.Raw {
		case "PONG":
			return nil
		default:
			return errors.New(fmt.Sprintf("Invalid response, got %s.", s))
		}
	}

	return nil
}
853512
func (p ManualProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	if p.ping != nil {
		return p.ping(endpoint)
	}
	return pingMachine(endpoint)
}
1094372
func (a *LBClient) Ping(waitFor time.Duration, timestamp *time.Time) error {
	glog.V(4).Infof("ControlCenterAgent.Ping()")
	return a.rpcClient.Call("ControlCenterAgent.Ping", waitFor, timestamp, 0)
}
86336
func (e *EnvironProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	return errors.NotImplementedf("Ping")
}
823768
func (l *Listener) Ping() error {
	l.lock.Lock()
	defer l.lock.Unlock()

	if l.isClosed {
		return errListenerClosed
	}
	if l.cn == nil {
		return errors.New("no connection")
	}

	return l.cn.Ping()
}
577972
func (s *Session) Ping() (time.Duration, error) {
	// Get a channel for the ping
	ch := make(chan struct{})

	// Get a new ping id, mark as pending
	s.pingLock.Lock()
	id := s.pingID
	s.pingID++
	s.pings[id] = ch
	s.pingLock.Unlock()

	// Send the ping request
	hdr := header(make([]byte, headerSize))
	hdr.encode(typePing, flagSYN, 0, id)
	if err := s.waitForSend(hdr, nil); err != nil {
		return 0, err
	}

	// Wait for a response
	start := time.Now()
	select {
	case <-ch:
	case <-time.After(s.config.ConnectionWriteTimeout):
		s.pingLock.Lock()
		delete(s.pings, id) // Ignore it if a response comes later.
		s.pingLock.Unlock()
		return 0, ErrTimeout
	case <-s.shutdownCh:
		return 0, ErrSessionShutdown
	}

	// Compute the RTT
	return time.Now().Sub(start), nil
}
402217
func (ins *instance) ping(timeout time.Duration) bool {
	session, err := mgo.DialWithTimeout(ins.url(), timeout)
	if err != nil {
		return false
	}
	defer session.Close()
	session.SetSyncTimeout(timeout)
	if err = session.Ping(); err != nil {
		return false
	}
	return true
}
706248
func (d *lbdgpro2whDevice) Ping(rw net.Conn, wait time.Duration) error {
	err := sendString("#PING\r\n", rw)
	if err != nil {
		return err
	}

	reader := bufio.NewReader(rw)
	endTime := time.Now().Add(wait)
	for {
		rw.SetReadDeadline(time.Now().Add(endTime.Sub(time.Now())))
		bytes, _, err := reader.ReadLine()
		rw.SetReadDeadline(time.Time{})
		if err != nil {
			return err
		}

		resp := string(bytes)
		if strings.Contains(resp, "~PING") {
			return nil
		}

		if time.Now().After(endTime) {
			return errors.New("timeout, no ping received")
		}
	}
}
507745
func (p MaasEnvironProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	base, version, includesVersion := gomaasapi.SplitVersionedURL(endpoint)
	if includesVersion {
		err := p.checkMaas(base, version)
		if err == nil {
			return nil
		}
	} else {
		// No version info in the endpoint - try both in preference order.
		err := p.checkMaas(endpoint, apiVersion2)
		if err == nil {
			return nil
		}
		err = p.checkMaas(endpoint, apiVersion1)
		if err == nil {
			return nil
		}
	}
	return errors.Errorf("No MAAS server running at %s", endpoint)
}