Skip to content

Commit

Permalink
Added optional argument key to create_message_set function
Browse files Browse the repository at this point in the history
  • Loading branch information
se7entyse7en committed Nov 26, 2014
1 parent 52ec078 commit 8138987
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kafka/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,17 @@ def create_snappy_message(payloads, key=None):
return Message(0, 0x00 | codec, key, snapped)


def create_message_set(messages, codec=CODEC_NONE):
def create_message_set(messages, codec=CODEC_NONE, key=None):
"""Create a message set using the given codec.
If codec is CODEC_NONE, return a list of raw Kafka messages. Otherwise,
return a list containing a single codec-encoded message.
"""
if codec == CODEC_NONE:
return [create_message(m) for m in messages]
return [create_message(m, key) for m in messages]
elif codec == CODEC_GZIP:
return [create_gzip_message(messages)]
return [create_gzip_message(messages, key)]
elif codec == CODEC_SNAPPY:
return [create_snappy_message(messages)]
return [create_snappy_message(messages, key)]
else:
raise UnsupportedCodecError("Codec 0x%02x unsupported" % codec)

0 comments on commit 8138987

Please sign in to comment.