func (c *Cluster) loop() {
	ticker := time.Tick(c.pingInterval)
	for {
		select {
		case <-ticker:
			go c.nodes.pingAll()
		case q := <-c.shutdown:
			q <- true
			return
		}
	}
}
loop is the event dispatcher for a Cluster. It manages the regular pinging of
Nodes, and serves incoming requests. Because every request against the
cluster must pass through here, it cannot block.
package elasticsearch
import (
	"time"
)
type Cluster struct {
	nodes        Nodes
	pingInterval time.Duration
	shutdown     chan chan bool
}
func NewCluster(endpoints []string, pingInterval, pingTimeout time.Duration) *Cluster {
	nodes := Nodes{}
	for _, endpoint := range endpoints {
		nodes = append(nodes, NewNode(endpoint, pingTimeout))
	}
	c := &Cluster{
		nodes:        nodes,
		pingInterval: pingInterval,
		shutdown:     make(chan chan bool),
	}
	go c.loop()
	return c
}