
from typing import override

from phederation.federation.tasks import BackgroundTask


class StorageBackgroundTask(BackgroundTask):

    @override
    async def on_startup(self):
        await super().on_startup()
        if self.server:
            await self.server.storage.initialize()

    @override
    async def on_shutdown(self):
        await super().on_shutdown()
        if self.server:
            await self.server.storage.close()
