当前位置: 首页>>代码示例>>Python>>正文


Python OwnedPartition.enqueue_messages方法代码示例

本文整理汇总了Python中pykafka.simpleconsumer.OwnedPartition.enqueue_messages方法的典型用法代码示例。如果您正苦于以下问题:Python OwnedPartition.enqueue_messages方法的具体用法?Python OwnedPartition.enqueue_messages怎么用?Python OwnedPartition.enqueue_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykafka.simpleconsumer.OwnedPartition的用法示例。


在下文中一共展示了OwnedPartition.enqueue_messages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_compacted_topic_partition_rejects_old_message_after_initial

# 需要导入模块: from pykafka.simpleconsumer import OwnedPartition [as 别名]
# 或者: from pykafka.simpleconsumer.OwnedPartition import enqueue_messages [as 别名]
    def test_compacted_topic_partition_rejects_old_message_after_initial(self):
        last_offset = 400
        message1 = mock.Mock()
        message1.value = "first-test"
        message1.partition_id = 0
        message1.offset = last_offset

        partition = mock.MagicMock()
        partition.id = 0
        op = OwnedPartition(partition, compacted_topic=True)
        op.enqueue_messages([message1])
        self.assertEqual(op.message_count, 1)
        consumed_msg = op.consume()
        self.assertEqual(op.message_count, 0)
        self.assertEqual(op.last_offset_consumed, last_offset)

        message2 = mock.Mock()
        message2.value = "test"
        message2.partition_id = 0
        message2.offset = 20

        op.enqueue_messages([message2])
        self.assertEqual(op.message_count, 0)
        op.consume()
        self.assertEqual(op.last_offset_consumed, last_offset)
开发者ID:kmgv,项目名称:pykafka,代码行数:27,代码来源:test_simpleconsumer.py

示例2: test_partition_rejects_old_message

# 需要导入模块: from pykafka.simpleconsumer import OwnedPartition [as 别名]
# 或者: from pykafka.simpleconsumer.OwnedPartition import enqueue_messages [as 别名]
    def test_partition_rejects_old_message(self):
        last_offset = 400
        op = OwnedPartition(None)
        op.last_offset_consumed = last_offset

        message = mock.Mock()
        message.value = "test"
        message.offset = 20

        op.enqueue_messages([message])
        self.assertEqual(op.message_count, 0)
        op.consume()
        self.assertEqual(op.last_offset_consumed, last_offset)
开发者ID:EricLau2018,项目名称:pykafka,代码行数:15,代码来源:test_simpleconsumer.py

示例3: test_partition_saves_offset

# 需要导入模块: from pykafka.simpleconsumer import OwnedPartition [as 别名]
# 或者: from pykafka.simpleconsumer.OwnedPartition import enqueue_messages [as 别名]
    def test_partition_saves_offset(self):
        msgval = "test"
        op = OwnedPartition(None)

        message = mock.Mock()
        message.value = msgval
        message.offset = 20

        op.enqueue_messages([message])
        self.assertEqual(op.message_count, 1)
        ret_message = op.consume()
        self.assertEqual(op.last_offset_consumed, message.offset)
        self.assertEqual(op.next_offset, message.offset + 1)
        self.assertNotEqual(ret_message, None)
        self.assertEqual(ret_message.value, msgval)
开发者ID:EricLau2018,项目名称:pykafka,代码行数:17,代码来源:test_simpleconsumer.py


注:本文中的pykafka.simpleconsumer.OwnedPartition.enqueue_messages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。