def supports_headers(self) -> bool: """Return :const:`True` if message headers are supported.""" producer = self._ensure_producer() client = producer.client if client is None: raise NotReady('Producer client not yet connected') return client.api_version >= (0, 11)
async def _get_controller_node(self, owner: Service, client: aiokafka.AIOKafkaClient, timeout: int = 30000) -> Optional[int]: nodes = [broker.nodeId for broker in client.cluster.brokers()] for node_id in nodes: if node_id is None: raise NotReady('Not connected to Kafka Broker') request = MetadataRequest_v1([]) wait_result = await owner.wait( client.send(node_id, request), timeout=timeout, ) if wait_result.stopped: owner.log.info(f'Shutting down - skipping creation.') return None response = wait_result.result return response.controller_id raise Exception(f'Controller node not found')
def _ensure_producer(self) -> aiokafka.BaseProducer: if self._producer is None: raise NotReady('Producer service not yet started') return self._producer
def supports_headers(self) -> bool: producer = self._ensure_producer() client = producer.client if client is None: raise NotReady('Producer client not yet connected') return client.api_version >= (0, 11)