async def _companion_to_target( self, companion: CompanionInfo) -> TargetDescription: channel = Channel(companion.host, companion.port, loop=asyncio.get_event_loop()) stub = CompanionServiceStub(channel=channel) response = await stub.describe(TargetDescriptionRequest()) channel.close() return target_to_py(response.target_description)
async def _companion_to_target( self, companion: CompanionInfo) -> Optional[TargetDescription]: try: channel = Channel(companion.host, companion.port, loop=asyncio.get_event_loop()) stub = CompanionServiceStub(channel=channel) response = await stub.describe(TargetDescriptionRequest()) channel.close() return target_to_py(response.target_description) except Exception: self.logger.warning(f"Failed to describe {companion}, removing it") self.direct_companion_manager.remove_companion( Address(companion.host, companion.port)) return None
async def describe(self) -> TargetDescription: async with self.get_stub() as stub: response = await stub.describe(TargetDescriptionRequest()) return target_to_py(response.target_description)
async def describe(self) -> TargetDescription: response = await self.stub.describe(TargetDescriptionRequest()) return target_to_py(response.target_description)
async def client(client: CompanionClient) -> TargetDescription: response = await client.stub.describe(TargetDescriptionRequest()) return target_to_py(response.target_description)
async def client(client: CompanionClient) -> List[TargetDescription]: response = await client.stub.list_targets(ListTargetsRequest()) return [target_to_py(target) for target in response.targets]
async def describe(self) -> TargetDescription: response = await self.stub.describe(TargetDescriptionRequest()) return target_to_py(target=response.target_description, companion_info=None)