Skip to content

Instantly share code, notes, and snippets.

@jacoelho
Created July 12, 2016 18:44
Show Gist options
  • Save jacoelho/28e767cad5ec5495276eefbe125d3b62 to your computer and use it in GitHub Desktop.
Save jacoelho/28e767cad5ec5495276eefbe125d3b62 to your computer and use it in GitHub Desktop.
custom resource list
def list(directory, zookeeper, topic)
cmd = %W(
#{directory}/bin/kafka-topics.sh
--zookeeper #{zookeeper}
--describe
--topic #{topic}
).join(" ")
result = shell_out(cmd).stdout
extract = ->(a) { a && a.to_i }
{
partitions: extract.call(result[/PartitionCount:\s*(\d+)/, 1]),
replicas: extract.call(result[/ReplicationFactor:\s*(\d+)/, 1])
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment