本文整理汇总了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)