From b8d419adcf1f65618a4cd27f44510135328705a4 Mon Sep 17 00:00:00 2001 From: matve Date: Fri, 29 Sep 2023 11:28:39 +0300 Subject: [PATCH] task/54 rename servises faxed rename classmethods --- sapphire/common/api/service.py | 8 ++++---- sapphire/common/broker/service.py | 10 +++++----- sapphire/common/database/service.py | 14 +++++++------- sapphire/projects/api/service.py | 2 +- sapphire/users/api/service.py | 2 +- sapphire/users/database/service.py | 2 +- sapphire/users/service.py | 2 +- tests/users/database/test_service.py | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sapphire/common/api/service.py b/sapphire/common/api/service.py index 41e5b9fa..0c7264c7 100644 --- a/sapphire/common/api/service.py +++ b/sapphire/common/api/service.py @@ -11,18 +11,18 @@ def __init__(self, title: str, version: str, port: int = 8000): self._version = version self._port = port - def base_get_app(self) -> fastapi.FastAPI: + def get_app(self) -> fastapi.FastAPI: app = fastapi.FastAPI(title=self._title, version=self._version) app.service = self - self.base_setup_app(app=app) + self.setup_app(app=app) return app - def base_setup_app(self, app: fastapi.FastAPI): + def setup_app(self, app: fastapi.FastAPI): pass async def start(self): - config = uvicorn.Config(app=self.base_get_app(), port=self._port) + config = uvicorn.Config(app=self.get_app(), port=self._port) server = UvicornServer(config) self.add_task(server.serve()) diff --git a/sapphire/common/broker/service.py b/sapphire/common/broker/service.py index 5afe97a6..0a31f51d 100644 --- a/sapphire/common/broker/service.py +++ b/sapphire/common/broker/service.py @@ -21,20 +21,20 @@ def __init__( ) self._producer = aiokafka.AIOKafkaProducer(bootstrap_servers=", ".join(servers)) - async def base_consume(self): + async def consume(self): await self._consumer.start() try: async for message in self._consumer: - await self.base_handle(message) + await self.handle(message) finally: await self._consumer.stop() - async def base_handle(self, message: aiokafka.ConsumerRecord): + async def handle(self, message: aiokafka.ConsumerRecord): for handler in self._handlers: if not await handler.check(message=message): continue await handler.handle(message=message) - async def base_start(self): - self.add_task(self.base_consume()) + async def start(self): + self.add_task(self.consume()) diff --git a/sapphire/common/database/service.py b/sapphire/common/database/service.py index 8912e16c..ccb025d9 100644 --- a/sapphire/common/database/service.py +++ b/sapphire/common/database/service.py @@ -12,11 +12,11 @@ def __init__(self, dsn: str): self._engine = create_async_engine(self._dsn) self._sessionmaker = async_sessionmaker(self._engine, expire_on_commit=False) - def base_get_alembic_config_path(self) -> pathlib.Path: + def get_alembic_config_path(self) -> pathlib.Path: raise NotImplementedError - def base_get_alembic_config(self) -> AlembicConfig: - migrations_path = self.base_get_alembic_config_path() + def get_alembic_config(self) -> AlembicConfig: + migrations_path = self.get_alembic_config_path() config = AlembicConfig() config.set_main_option("script_location", str(migrations_path)) @@ -24,8 +24,8 @@ def base_get_alembic_config(self) -> AlembicConfig: return config - def bae_migrate(self): - alembic_command.upgrade(self.base_get_alembic_config(), "head") + def migrate(self): + alembic_command.upgrade(self.get_alembic_config(), "head") - def base_create_migration(self, message: str | None = None): - alembic_command.revision(self.base_get_alembic_config(), message=message, autogenerate=True) + def create_migration(self, message: str | None = None): + alembic_command.revision(self.get_alembic_config(), message=message, autogenerate=True) diff --git a/sapphire/projects/api/service.py b/sapphire/projects/api/service.py index 26af877d..43c839ae 100644 --- a/sapphire/projects/api/service.py +++ b/sapphire/projects/api/service.py @@ -11,7 +11,7 @@ class ProjectsAPIService(BaseAPIService): def __init__(self, version: str, port: int = 8000): super().__init__(title="Projects", version=version, port=port) - def base_setup_app(self, app: fastapi.FastAPI): + def setup_app(self, app: fastapi.FastAPI): app.include_router(router, prefix="/api") diff --git a/sapphire/users/api/service.py b/sapphire/users/api/service.py index 6102d4c6..e9ed6356 100644 --- a/sapphire/users/api/service.py +++ b/sapphire/users/api/service.py @@ -23,7 +23,7 @@ def __init__( super().__init__(title="Users", version=version, port=port) - def base_setup_app(self, app: fastapi.FastAPI): + def setup_app(self, app: fastapi.FastAPI): app.include_router(router, prefix="/api") @property diff --git a/sapphire/users/database/service.py b/sapphire/users/database/service.py index d7ac9662..60da1d17 100644 --- a/sapphire/users/database/service.py +++ b/sapphire/users/database/service.py @@ -5,7 +5,7 @@ class UsersDatabaseService(BaseDatabaseService): - def base_get_alembic_config_path(self) -> pathlib.Path: + def get_alembic_config_path(self) -> pathlib.Path: return pathlib.Path(__file__).parent / "migrations" diff --git a/sapphire/users/service.py b/sapphire/users/service.py index 3b13f8fe..ecb8f42c 100644 --- a/sapphire/users/service.py +++ b/sapphire/users/service.py @@ -14,7 +14,7 @@ def __init__(self, database: UsersDatabaseService, version: str = "0.0.0", port: super().__init__(title="Users", version=version, port=port) - def base_setup_app(self, app: fastapi.FastAPI): + def setup_app(self, app: fastapi.FastAPI): app.include_router(api.router, prefix="/api") @property diff --git a/tests/users/database/test_service.py b/tests/users/database/test_service.py index 43c66160..090ced3e 100644 --- a/tests/users/database/test_service.py +++ b/tests/users/database/test_service.py @@ -9,7 +9,7 @@ def test_get_alembic_config_path(database_service: UsersDatabaseService): pathlib.Path(os.curdir).absolute() / "sapphire" / "users" / "database" / "migrations" ) - path = database_service.base_get_alembic_config_path() + path = database_service.get_alembic_config_path() assert isinstance(path, pathlib.Path) assert path == expected_path