Skip to content

Instantly share code, notes, and snippets.

@zsol
Created September 9, 2012 06:20
Show Gist options
  • Save zsol/3682934 to your computer and use it in GitHub Desktop.
Save zsol/3682934 to your computer and use it in GitHub Desktop.

Revisions

  1. zsol created this gist Sep 9, 2012.
    19 changes: 19 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    from kazoo.client import KazooClient

    config = {
    'consumer_group': '<%= @consumer_group %>',
    'topic': '<%= @topic %>'
    }

    def main():
    zk = KazooClient()
    zk.start()
    partitions = zk.get_children('/consumers/%(consumer_group)s/offsets/%(topic)s' % config)
    num_partitions = int(zk.get('/brokers/topics/%(topic)s/0' % config)[0])
    if len(partitions) != num_partitions:
    print "Croak! Partition fluctuation"
    return
    # and now go and connect to the broker and get the last offset available...

    if __name__ == '__main__':
    main()