elasticstream/cmd/main.go

40 lines
643 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",
2024-10-07 09:50:00 +05:30
Indexes: []string{"index-a", "index-b", "index-c"},
2024-10-03 12:40:46 +05:30
BatchSize: 10,
2024-10-07 09:50:00 +05:30
DBPath: "./index.db",
2024-10-03 12:40:46 +05:30
}
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)
}
}