本文整理匯總了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'))