本文整理汇总了Python中afkak.kafkacodec.KafkaCodec._decode_message_set_iter方法的典型用法代码示例。如果您正苦于以下问题:Python KafkaCodec._decode_message_set_iter方法的具体用法?Python KafkaCodec._decode_message_set_iter怎么用?Python KafkaCodec._decode_message_set_iter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类afkak.kafkacodec.KafkaCodec
的用法示例。
在下文中一共展示了KafkaCodec._decode_message_set_iter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_decode_message_set_stop_iteration
# 需要导入模块: from afkak.kafkacodec import KafkaCodec [as 别名]
# 或者: from afkak.kafkacodec.KafkaCodec import _decode_message_set_iter [as 别名]
def test_decode_message_set_stop_iteration(self):
encoded = b"".join([
struct.pack(">q", 0), # MsgSet Offset
struct.pack(">i", 18), # Msg Size
struct.pack(">i", 1474775406), # CRC
struct.pack(">bb", 0, 0), # Magic, flags
struct.pack(">i", 2), # Length of key
b"k1", # Key
struct.pack(">i", 2), # Length of value
b"v1", # Value
struct.pack(">q", 1), # MsgSet Offset
struct.pack(">i", 18), # Msg Size
struct.pack(">i", -16383415), # CRC
struct.pack(">bb", 0, 0), # Magic, flags
struct.pack(">i", 2), # Length of key
b"k2", # Key
struct.pack(">i", 2), # Length of value
b"v2", # Value
b"@1$%(Y!", # Random padding
])
msgs = list(KafkaCodec._decode_message_set_iter(encoded))
self.assertEqual(len(msgs), 2)
msg1, msg2 = msgs
returned_offset1, decoded_message1 = msg1
returned_offset2, decoded_message2 = msg2
self.assertEqual(returned_offset1, 0)
self.assertEqual(decoded_message1, create_message(b"v1", b"k1"))
self.assertEqual(returned_offset2, 1)
self.assertEqual(decoded_message2, create_message(b"v2", b"k2"))
示例2: test_decode_message_set_fetch_size_too_small
# 需要导入模块: from afkak.kafkacodec import KafkaCodec [as 别名]
# 或者: from afkak.kafkacodec.KafkaCodec import _decode_message_set_iter [as 别名]
def test_decode_message_set_fetch_size_too_small(self):
self.assertRaises(ConsumerFetchSizeTooSmall,
list, KafkaCodec._decode_message_set_iter('a'))