Some Kafka experiments.
Requires configuring the env vars:
export B=k4fk4.io:9093
export T=topic
export U=user
export P=password
Simple CLI to produce and consume data.
Produce:
> fortune -s | oq
Consume:
> oq
Today is what happened to yesterday.
A Go client to simply produce and consume.
// 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))
}
Produce or consume in Kafka over WebSockets.
Register scripts or go funcs to be executed when a message contains a string.
bot.NewBot(fmt.Sprintf("koko-%s-bot", hostname)).
RegisterScript("bam", "scripts/bam.sh").
RegisterCmdFunc("ping", func(args ...string) string {
return "pong"
}).
Start()