https://github.com/thbkrkr/qli
Kafka experiments
https://github.com/thbkrkr/qli
kafka
Last synced: 3 months ago
JSON representation
Kafka experiments
- Host: GitHub
- URL: https://github.com/thbkrkr/qli
- Owner: thbkrkr
- Created: 2016-07-12T06:56:17.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T19:46:03.000Z (about 8 years ago)
- Last Synced: 2025-03-02T17:48:18.074Z (over 1 year ago)
- Topics: kafka
- Language: Go
- Size: 6.59 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Qli
[](https://travis-ci.org/thbkrkr/qli)
Some Kafka experiments.
Requires configuring the env vars:
```sh
export B=k4fk4.io:9093
export T=topic
export U=user
export P=password
```
### qli/oq
Simple CLI to produce and consume data.
Produce:
```sh
> fortune -s | oq
```
Consume:
```
> oq
Today is what happened to yesterday.
```
### qli/client
A Go client to simply produce and consume.
```go
// Create client
q, err := client.NewClientFromEnv(client)
// Produce one message synchronously
partition, offset, err := q.Send(data)
// Produce messages asynchronously
pub, err := q.Pub()
pub, err := q.PubOn(topic)
for stdin.Scan() {
pub <- stdin.Bytes()
}
// Consume messages asynchronously
sub, err := q.Sub()
sub, err := q.SubOn(topic)
for msg := range sub {
fmt.Println(string(msg))
}
```
### qli/qws
Produce or consume in Kafka over WebSockets.
### qli/bot
Register scripts or go funcs to be executed when a message contains a string.
```go
bot.NewBot(fmt.Sprintf("koko-%s-bot", hostname)).
RegisterScript("bam", "scripts/bam.sh").
RegisterCmdFunc("ping", func(args ...string) string {
return "pong"
}).
Start()
```