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


Python ConsumerCoordinator._maybe_auto_commit_offsets_sync方法代码示例

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


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

示例1: test_maybe_auto_commit_offsets_sync

# 需要导入模块: from kafka.coordinator.consumer import ConsumerCoordinator [as 别名]
# 或者: from kafka.coordinator.consumer.ConsumerCoordinator import _maybe_auto_commit_offsets_sync [as 别名]
def test_maybe_auto_commit_offsets_sync(mocker, api_version, group_id, enable,
                                        error, has_auto_commit, commit_offsets,
                                        warn, exc):
    mock_warn = mocker.patch('kafka.coordinator.consumer.log.warning')
    mock_exc = mocker.patch('kafka.coordinator.consumer.log.exception')
    client = KafkaClient(api_version=api_version)
    coordinator = ConsumerCoordinator(client, SubscriptionState(),
                                      Metrics(), 'consumer',
                                      api_version=api_version,
                                      enable_auto_commit=enable,
                                      group_id=group_id)
    commit_sync = mocker.patch.object(coordinator, 'commit_offsets_sync',
                                      side_effect=error)
    if has_auto_commit:
        assert coordinator._auto_commit_task is not None
    else:
        assert coordinator._auto_commit_task is None

    assert coordinator._maybe_auto_commit_offsets_sync() is None

    if has_auto_commit:
        assert coordinator._auto_commit_task is not None

    assert commit_sync.call_count == (1 if commit_offsets else 0)
    assert mock_warn.call_count == (1 if warn else 0)
    assert mock_exc.call_count == (1 if exc else 0)
开发者ID:0ste00,项目名称:kafka-python,代码行数:28,代码来源:test_coordinator.py


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