elasticstream/cmd/main.go

45 lines
721 B
Go
Raw Normal View History

2024-10-03 12:40:46 +05:30
package main
import (
"fmt"
"log"
"11-11.dev/goexamples/elasticstream"
)
func main() {
client, err := elasticstream.NewClient()
if err != nil {
log.Println("elasticstream.NewClient() err:", err)
return
}
config := &elasticstream.Config{
Host: "http://localhost:9200",
Indexes: map[string]int{"users": 0, "students": 0, "teachers": 0},
BatchSize: 10,
}
err = client.Configure(config)
if err != nil {
log.Println("client.Configure() 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)
}
}