本文整理汇总了Python中aiokafka.client.AIOKafkaClient._send_broker_unaware_request方法的典型用法代码示例。如果您正苦于以下问题:Python AIOKafkaClient._send_broker_unaware_request方法的具体用法?Python AIOKafkaClient._send_broker_unaware_request怎么用?Python AIOKafkaClient._send_broker_unaware_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiokafka.client.AIOKafkaClient
的用法示例。
在下文中一共展示了AIOKafkaClient._send_broker_unaware_request方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_broker_unaware_request
# 需要导入模块: from aiokafka.client import AIOKafkaClient [as 别名]
# 或者: from aiokafka.client.AIOKafkaClient import _send_broker_unaware_request [as 别名]
def test_send_broker_unaware_request(self):
"Tests that call works when at least one of the host is available"
mocked_conns = {
("kafka01", 9092): mock.MagicMock(),
("kafka02", 9092): mock.MagicMock(),
("kafka03", 9092): mock.MagicMock(),
}
# inject KafkaConnection side effects
fut = asyncio.Future(loop=self.loop)
fut.set_exception(RuntimeError("kafka01 went away (unittest)"))
mocked_conns[("kafka01", 9092)].send.return_value = fut
fut2 = asyncio.Future(loop=self.loop)
fut2.set_result(b"valid response")
mocked_conns[("kafka02", 9092)].send.return_value = fut2
fut3 = asyncio.Future(loop=self.loop)
fut3.set_exception(RuntimeError("kafka03 went away (unittest)"))
mocked_conns[("kafka03", 9092)].send.return_value = fut3
client = AIOKafkaClient("kafka01:9092,kafka02:9092", loop=self.loop)
client._conns = mocked_conns
resp = self.loop.run_until_complete(
client._send_broker_unaware_request(
payloads=[b"fake request"], encoder_fn=mock.MagicMock(), decoder_fn=lambda x: x
)
)
self.assertEqual(b"valid response", resp)