Skip to content

Commit

Permalink
add details for getting topic info
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaemming committed Dec 10, 2015
1 parent 314d818 commit 07cd24b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions kafkaesque/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import itertools
import logging
import operator
import tabulate
import time

import click
Expand Down Expand Up @@ -97,6 +98,28 @@ def consume(topic, follow, fetch_size):
)


@cli.command()
@click.argument('topic')
def details(topic):
client = StrictRedis()
with client.pipeline(transaction=False) as pipeline:
pipeline.hgetall(topic)
pipeline.zcard('{}/pages'.format(topic))
pipeline.zrange('{}/pages'.format(topic), -10, -1, withscores=True)
results = pipeline.execute()

def header(label):
return '\n'.join(('-' * 80, label, '-' * 80))

print header('CONFIGURATION')
print tabulate.tabulate(results[0].items(), headers=('key', 'value'))

print ''

print header('PAGES ({} total)'.format(results[1]))
print tabulate.tabulate(results[2], headers=('page', 'offset'))


if __name__ == '__main__':
logging.basicConfig(
level=logging.DEBUG,
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
install_requires=(
'click',
'redis',
'tabulate',
),
tests_require=(
'pytest',
Expand Down

0 comments on commit 07cd24b

Please sign in to comment.