Mongey / ksql

A barebones go client for interacting with Confluent's KSQL Server
13 stars 10 forks source link
kafka ksql

KSQL go client

GoDoc CircleCI

A barebones go client for interacting with Confluent's KSQL

Examples

List all Streams

    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

    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

    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)
        }
    }