コード例 #1
0
func newCluster(t *testing.T, indices []string, m map[string]interface{}) *es.Cluster {
	deleteIndices(t, indices)
	loadData(t, m)

	endpoints := []string{"http://localhost:9200"}
	pingInterval, pingTimeout := 10*time.Second, 3*time.Second
	return es.NewCluster(endpoints, pingInterval, pingTimeout)
}
コード例 #2
0
ファイル: cluster.go プロジェクト: bernerdschaefer/esmc
// Connects to a cluster using the provided Config.
func NewCluster(config Config) *Cluster {
	return &Cluster{
		Name: config.Name(),
		Mode: config.Mode(),
		cluster: es.NewCluster(
			config.Endpoints,
			config.PingInterval(),
			config.PingTimeout(),
		),
	}
}
コード例 #3
0
// Just tests es.Cluster internals; doesn't make any real connection.
func TestClusterShutdown(t *testing.T) {
	endpoints := []string{"http://host1:9200", "http://host2:9200"}
	pingInterval, pingTimeout := 30*time.Second, 3*time.Second
	c := es.NewCluster(endpoints, pingInterval, pingTimeout)

	e := make(chan error)
	go func() {
		c.Shutdown()
		e <- nil
	}()
	go func() {
		<-time.After(1 * time.Second)
		e <- fmt.Errorf("timeout")
	}()

	if err := <-e; err != nil {
		t.Fatalf("%s", err)
	}
}