A barebones go client for interacting with Confluent's KSQL
c := ksql.NewClient("http://localhost:8088")
log.Println("=>>> Streams")
streams, err := c.ListStreams()
if err != nil {
log.Fatal(err)
}
for i, v := range streams {
log.Printf("Stream %d: %s", i, v.Name)
}
c := ksql.NewClient("http://localhost:8088")
log.Println("=>>> Tables")
tables, err := c.ListTables()
if err != nil {
log.Fatal(err)
}
for i, v := range tables {
log.Printf("Table %d: %s", i, v.Name)
}
c := ksql.NewClient("http://localhost:8088")
log.Println("=>>> Forever Query :")
ch := make(chan *ksql.QueryResponse)
go c.Query(ksql.Request{KSQL: "SELECT pageid FROM pageviews_original;"}, ch)
for {
select {
case msg := <-ch:
log.Println(msg.Row)
}
}