Created
July 12, 2016 18:44
-
-
Save jacoelho/28e767cad5ec5495276eefbe125d3b62 to your computer and use it in GitHub Desktop.
custom resource list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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