66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
import uuid
|
|
from datetime import timedelta
|
|
from typing import AsyncContextManager, AsyncGenerator, Protocol
|
|
|
|
from birthday_pool_bot.dto import Pool, User
|
|
|
|
|
|
class MessengerInterface(Protocol):
|
|
async def send_message(self, chat_id: str, message: str):
|
|
raise NotImplementedError
|
|
|
|
|
|
class MigratorInterface(Protocol):
|
|
def get_migrations_directory_path(self) -> pathlib.Path:
|
|
raise NotImplementedError
|
|
|
|
def get_current_migration(self) -> str | None:
|
|
raise NotImplementedError
|
|
|
|
def get_latest_migration(self) -> str | None:
|
|
raise NotImplementedError
|
|
|
|
def get_migrations(self) -> Generator[str, None, None]:
|
|
raise NotImplementedError
|
|
|
|
def create_migration(
|
|
self,
|
|
migration_id: str | None = None,
|
|
**kwargs,
|
|
) -> str:
|
|
raise NotImplementedError
|
|
|
|
def migrate(self, migration_id: str | None = None, **kwargs) -> str | None:
|
|
raise NotImplementedError
|
|
|
|
def rollback(self, migration_id: str | None = None, **kwargs) -> str | None:
|
|
raise NotImplementedError
|
|
|
|
def squash_migrations(
|
|
self,
|
|
new_migration_id: str | None = None,
|
|
**kwargs,
|
|
) -> str:
|
|
raise NotImplementedError
|
|
|
|
|
|
class RepositoryInterface(Protocol):
|
|
def transaction(self) -> AsyncContextManager:
|
|
raise NotImplementedError
|
|
|
|
|
|
class CacheInterface(Protocol):
|
|
async def set(
|
|
self,
|
|
key: str,
|
|
value: Any,
|
|
ttl: timedelta | None = None,
|
|
):
|
|
raise NotImplementedError
|
|
|
|
async def get(self, key: str) -> Any:
|
|
raise NotImplementedError
|
|
|
|
async def delete(self, key: str):
|
|
raise NotImplementedError
|