Cache serialize of manifest for loaded integrations (#117965)

* Cache serialize of manifest for loaded integrations

The manifest/list and manifest/get websocket apis
are called frequently when moving around in the UI.
Since the manifest does not change we can make
the the serialized version a cached property

* reduce

* reduce
This commit is contained in:
J. Nick Koston
2024-05-23 04:52:05 -10:00
committed by GitHub
parent 09e7156d2d
commit c5cc9801a6
3 changed files with 26 additions and 12 deletions

View File

@@ -39,6 +39,7 @@ from .generated.mqtt import MQTT
from .generated.ssdp import SSDP
from .generated.usb import USB
from .generated.zeroconf import HOMEKIT, ZEROCONF
from .helpers.json import json_bytes, json_fragment
from .util.hass_dict import HassKey
from .util.json import JSON_DECODE_EXCEPTIONS, json_loads
@@ -762,6 +763,11 @@ class Integration:
self._top_level_files = top_level_files or set()
_LOGGER.info("Loaded %s from %s", self.domain, pkg_path)
@cached_property
def manifest_json_fragment(self) -> json_fragment:
"""Return manifest as a JSON fragment."""
return json_fragment(json_bytes(self.manifest))
@cached_property
def name(self) -> str:
"""Return name."""