elasticstream/cmd/main.go

39 lines
613 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() {
config := &elasticstream.Config{
2024-10-03 14:04:17 +05:30
Host: "http://test.urantiacloud.com:9200",
Indexes: []string{"IndexA", "IndexB", "IndexC"},
2024-10-03 12:40:46 +05:30
BatchSize: 10,
}
2024-10-03 12:57:23 +05:30
client, err := elasticstream.NewClient(config)
2024-10-03 12:40:46 +05:30
if err != nil {
2024-10-03 12:57:23 +05:30
log.Println("elasticstream.NewClient() err:", err)
2024-10-03 12:40:46 +05:30
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)
}
}