func (c *Cluster) Shutdown() {
	q := make(chan bool)
	c.shutdown <- q
	<-q
}
Shutdown terminates the Cluster's event dispatcher.
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
}
func (c *Cluster) loop() {
	ticker := time.Tick(c.pingInterval)
	for {
		select {
		case <-ticker:
			go c.nodes.pingAll()
		case q := <-c.shutdown:
			q <- true
			return
		}
	}
}
func (c *Cluster) Search(r SearchRequest) (response SearchResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) MultiSearch(r MultiSearchRequest) (response MultiSearchResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) Index(r IndexRequest) (response IndexResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) Create(r CreateRequest) (response IndexResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) Update(r UpdateRequest) (response IndexResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) Delete(r DeleteRequest) (response IndexResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) Bulk(r BulkRequest) (response BulkResponse, err error) {
	err = c.Execute(r, &response)
	return
}
func (c *Cluster) Execute(f Fireable, response interface{}) error {
	node, err := c.nodes.getBest()
	if err != nil {
		return err
	}
	return node.Execute(f, response)
}