elasticstream/cmd/main.go

39 lines
619 B
Go

package main
import (
"fmt"
"log"
"11-11.dev/goexamples/elasticstream"
)
func main() {
config := &elasticstream.Config{
Host: "http://localhost:9200",
Indexes: map[string]int{"users": 0, "students": 0, "teachers": 0},
BatchSize: 10,
}
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)
}
}