Project

kazoo-ruby

0.02
No commit activity in last 3 years
No release in over 3 years
Library to access and manipulate Kafka metadata in Zookeeper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 1.1
~> 10.0

Runtime

~> 0.19.1
~> 1.4
 Project Readme

Kazoo

Ruby library to access and manipulate Kafka metadata in Zookeeper

Usage

First, make kazoo available by adding it to your Gemfile

gem 'kazoo-ruby', require: 'kazoo'

Now, you can interact with the cluster metadata as follows:

# Connect to the Zookeeper cluster that backs your Kafka cluster
cluster = Kazoo::Cluster.new('zookeeper1:2181,zookeeper2:2181/chroot')

# List the brokers that form the Kafka cluster
cluster.brokers.each do |id, broker|
  puts "Broker #{broker.id}: #{broker.addr}"
end

# Inspect topic/partition metadata
cluster.topics.each do |name, topic|
  puts "#{name}: #{topic.partitions.length} partitions"
end

# List consumers
cluster.consumergroups.each do |name, group|
  puts "Consumer #{name}: #{group.instances.length} running instances"
end

Binary

This gem also comes with a simple kazoo binary to inspect your kafka cluster:

# Describe the brokers that compose the cluster
$ kazoo cluster --zookeeper zk1:2181,zk2:2181,zk3:2181/chroot

# List all topics or partitions in the cluster
$ kazoo topics --zookeeper zk1:2181,zk2:2181,zk3:2181/chroot
$ kazoo partitions --topic=access_log --zookeeper zk1:2181,zk2:2181,zk3:2181/chroot

Contributing

  1. Fork it ( https://github.com/wvanbergen/kazoo/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

See also

  • kafka-consumer: a high-level Kafka consumer library that coordinates running instances using Zookeeper.