kafka-cli

command module
v0.0.0-...-b513e57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2018 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Install

go get github.com/zhuangsirui/kafka-cli

Examples

Simply call kafka-cli after install

connect

disconnected > connect --addrs broker-1:port,broker-2:port,broker-3:port
connecting... [broker-1:port broker-2:port broker-3:port]
connected >

disconnect

connected > disconnect
disconnected >

list

list topics
connected > list topics
[topic-1 topic-2]
list partitions
connected > list partitions --topic topic-1
[0 1 2]

get

get offset
connected > get offset --topic topic-1 --partition 0 # default for the newest offset on the partition
10
connected > get offset --topic topic-1 --partition 0 --time -2 # you can set `--time -2` to show oldest offset on the partition
0

produce

connected > produce --topic test --partition 0 --key 'key for the log' --value 'value for the log'
produce successful, offset 10

consume

connected > consume --topic test --partition 0
{"key":"key","value":"value","offset":0}
{"key":"key","value":"value","offset":1}
{"key":"key","value":"value","offset":2}
{"key":"key","value":"value","offset":3}
{"key":"key","value":"value","offset":4}
{"key":"key","value":"value","offset":5}
{"key":"key","value":"value","offset":6}
{"key":"key","value":"value","offset":7}
{"key":"key","value":"value","offset":8}
{"key":"key","value":"value","offset":9}
{"key":"key for the log","value":"value for the log","offset":10} # C^c to stop consume
connected >

You can set --output to assign where to print the consume data

connected > consume --topic test --partition 0 --output ./topic-test-0.json # C^c to stop consume
connected >
$ cat ./topic-test-0.json
{"key":"key","value":"value","offset":0}
{"key":"key","value":"value","offset":1}
{"key":"key","value":"value","offset":2}
{"key":"key","value":"value","offset":3}
{"key":"key","value":"value","offset":4}
{"key":"key","value":"value","offset":5}
{"key":"key","value":"value","offset":6}
{"key":"key","value":"value","offset":7}
{"key":"key","value":"value","offset":8}
{"key":"key","value":"value","offset":9}
{"key":"key for the log","value":"value for the log","offset":10}

more flags at consume --help

non-interactive mode

You can add --addrs flags after kafka-cli and run what you want directly from shell:

$ kafka-cli --addrs broker-0:port produce --topic test --partition 0 --key 'key from bash' --value 'value from bash'
produce successful, offset 11

TODO

  • Make some examples on readme
  • Support csv output
  • Create/delete topic

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址