thbkrkr / qli

Kafka experiments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Qli

Build Status

Some Kafka experiments.

Requires configuring the env vars:

export B=k4fk4.io:9093
export T=topic
export U=user
export P=password

qli/oq

Simple CLI to produce and consume data.

Produce:

> fortune -s | oq

Consume:

> oq
Today is what happened to yesterday.

qli/client

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

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.

bot.NewBot(fmt.Sprintf("koko-%s-bot", hostname)).
  RegisterScript("bam", "scripts/bam.sh").
  RegisterCmdFunc("ping", func(args ...string) string {
    return "pong"
  }).
  Start()

About

Kafka experiments


Languages

Language:Go 58.9%Language:HTML 36.9%Language:Makefile 1.7%Language:Shell 1.1%Language:CSS 0.8%Language:JavaScript 0.6%