elasticstream/cmd/main.go

40 lines
643 B
Go

package main
import (
"fmt"
"log"
"11-11.dev/goexamples/elasticstream"
)
func main() {
config := &elasticstream.Config{
Host: "http://test.urantiacloud.com:9200",
Indexes: []string{"index-a", "index-b", "index-c"},
BatchSize: 10,
DBPath: "./index.db",
}
client, err := elasticstream.NewClient(config)
if err != nil {
log.Println("elasticstream.NewClient() err:", err)
return
}
err = client.Open()
if err != nil {
log.Println("client.Open() err:", err)
return
}
for {
data, err := client.Read()
if err != nil {
log.Println("eclient.Read() err:", err)
continue
}
fmt.Println(data)
}
}