https://github.com/mongey/ksql
A barebones go client for interacting with Confluent's KSQL Server
https://github.com/mongey/ksql
kafka ksql
Last synced: 2 months ago
JSON representation
A barebones go client for interacting with Confluent's KSQL Server
- Host: GitHub
- URL: https://github.com/mongey/ksql
- Owner: Mongey
- Created: 2018-05-08T21:28:21.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T23:56:47.000Z (over 5 years ago)
- Last Synced: 2025-05-07T04:03:44.700Z (2 months ago)
- Topics: kafka, ksql
- Language: Go
- Size: 3.93 MB
- Stars: 14
- Watchers: 2
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# KSQL go client
[][godoc]
[][ci]A barebones go client for interacting with [Confluent's KSQL][ksql]
## Examples
#### List all Streams
```go
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)
}
```#### List all Tables
```go
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)
}
```#### Query stream
```go
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)
}
}
```
[godoc]: https://godoc.org/github.com/Mongey/ksql/ksql
[ksql]: https://www.confluent.io/product/ksql/
[ci]: https://circleci.com/gh/Mongey/ksql