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


Python OwnedPartition.build_offset_commit_request方法代码示例

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


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

示例1: test_partition_offset_commit_request

# 需要导入模块: from pykafka.simpleconsumer import OwnedPartition [as 别名]
# 或者: from pykafka.simpleconsumer.OwnedPartition import build_offset_commit_request [as 别名]
    def test_partition_offset_commit_request(self):
        topic = mock.Mock()
        topic.name = "test_topic"
        partition = mock.Mock()
        partition.topic = topic
        partition.id = 12345

        op = OwnedPartition(partition)
        op.last_offset_consumed = 200

        request = op.build_offset_commit_request()

        self.assertEqual(request.topic_name, topic.name)
        self.assertEqual(request.partition_id, partition.id)
        self.assertEqual(request.offset, op.last_offset_consumed + 1)
        self.assertEqual(request.metadata, b'pykafka')
开发者ID:raghavtan,项目名称:pykafka,代码行数:18,代码来源:test_simpleconsumer.py

示例2: test_partition_offset_commit_request

# 需要导入模块: from pykafka.simpleconsumer import OwnedPartition [as 别名]
# 或者: from pykafka.simpleconsumer.OwnedPartition import build_offset_commit_request [as 别名]
    def test_partition_offset_commit_request(self):
        topic = mock.Mock()
        topic.name = "test_topic"
        partition = mock.Mock()
        partition.topic = topic
        partition.id = 12345

        op = OwnedPartition(partition)
        op.last_offset_consumed = 200

        request = op.build_offset_commit_request()

        self.assertEqual(request.topic_name, topic.name)
        self.assertEqual(request.partition_id, partition.id)
        self.assertEqual(request.offset, op.last_offset_consumed + 1)
        parsed_metadata = json.loads(get_string(request.metadata))
        self.assertEqual(parsed_metadata["consumer_id"], '')
        self.assertTrue(bool(parsed_metadata["hostname"]))
开发者ID:kmgv,项目名称:pykafka,代码行数:20,代码来源:test_simpleconsumer.py

示例3: test_partition_offset_commit_request

# 需要导入模块: from pykafka.simpleconsumer import OwnedPartition [as 别名]
# 或者: from pykafka.simpleconsumer.OwnedPartition import build_offset_commit_request [as 别名]
    def test_partition_offset_commit_request(self):
        topic = mock.Mock()
        topic.name = "test_topic"
        partition = mock.Mock()
        partition.topic = topic
        partition.id = 12345

        op = OwnedPartition(partition)
        op.last_offset_consumed = 200

        rqtime = int(time.time())
        request = op.build_offset_commit_request()

        self.assertEqual(request.topic_name, topic.name)
        self.assertEqual(request.partition_id, partition.id)
        self.assertEqual(request.offset, op.last_offset_consumed)
        # sketchy, but it works because of second resolution
        self.assertEqual(request.timestamp, rqtime)
        self.assertEqual(request.metadata, 'pykafka')
开发者ID:preoctopus,项目名称:pykafka,代码行数:21,代码来源:test_simpleconsumer.py


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