from __future__ import annotations from dataclasses import dataclass from yuxi.channel.domain.model.plugin_registry.plugin_registry import RegistrySnapshot @dataclass class SnapshotResult: snapshot: RegistrySnapshot plugin_count: int adapter_count: int def take_snapshot(registry: object) -> SnapshotResult: from yuxi.channel.domain.model.plugin_registry.plugin_registry import PluginRegistry if not isinstance(registry, PluginRegistry): raise TypeError("registry must be PluginRegistry") snap = registry.snapshot() return SnapshotResult( snapshot=snap, plugin_count=len(snap.plugins), adapter_count=len(snap.adapters), ) def restore_snapshot(registry: object, snapshot: RegistrySnapshot) -> None: from yuxi.channel.domain.model.plugin_registry.plugin_registry import PluginRegistry if not isinstance(registry, PluginRegistry): raise TypeError("registry must be PluginRegistry") registry.restore(snapshot)