func (n *Node) GetHealth() Health {
	n.RLock()
	defer n.RUnlock()
	return n.health
}
GetHealth returns the health of the node, for use in the Cluster's GetBest.
package elasticsearch
import (
	"encoding/json"
	"fmt"
	"log"
	"math/rand"
	"net"
	"net/http"
	"net/url"
	"sync"
	"time"
)
type Node struct {
	sync.RWMutex
	endpoint   string
	health     Health
	client     *http.Client  
	pingClient *http.Client  
}
func NewNode(endpoint string, pingTimeout time.Duration) *Node {
	return &Node{
		endpoint: endpoint,
		health:   Yellow,
		client: &http.Client{
			Transport: &http.Transport{
				MaxIdleConnsPerHost: 250,
			},
		},
		pingClient: &http.Client{
			Transport: &http.Transport{
				Dial: timeoutDialer(pingTimeout),
			},
		},
	}
}
func (n *Node) Ping() bool {
	u, err := url.Parse(n.endpoint)
	if err != nil {
		log.Printf("ElasticSearch: ping: resolve: %s", err)
		return false
	}
	u.Path = "/_cluster/nodes/_local"  
	resp, err := n.pingClient.Get(u.String())
	if err != nil {
		log.Printf("ElasticSearch: ping %s: GET: %s", u.Host, err)
		return false
	}
	defer resp.Body.Close()
	var status struct {
		OK bool `json:"ok"`
	}
	if err = json.NewDecoder(resp.Body).Decode(&status); err != nil {
		log.Printf("ElasticSearch: ping %s: %s", u.Host, err)
		return false
	}
	if !status.OK {
		log.Printf("ElasticSearch: ping %s: ok=false", u.Host)
		return false
	}
	return true
}
func (n *Node) pingAndSet() {
	success := n.Ping()
	func() {
		n.Lock()
		defer n.Unlock()
		if success {
			n.health = n.health.Improve()
		} else {
			n.health = n.health.Degrade()
		}
	}()
}