Skip to content

Commit 09b4aba

Browse files
author
maxim-lixakov
committed
[DOP-21268] - split Settings to SyncmasterSettings, WorkerSettings(SyncmasterSettings), BackendSettings(SyncmasterSettings)
1 parent 99d1cf1 commit 09b4aba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+127
-101
lines changed

syncmaster/backend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from syncmaster.backend.middlewares import apply_middlewares
1818
from syncmaster.backend.providers.auth import AuthProvider
1919
from syncmaster.backend.services.unit_of_work import UnitOfWork
20+
from syncmaster.backend.settings import BackendSettings as Settings
2021
from syncmaster.db.factory import create_session_factory, get_uow
2122
from syncmaster.exceptions import SyncmasterError
22-
from syncmaster.settings import Settings
2323

2424

2525
def application_factory(settings: Settings) -> FastAPI:

syncmaster/backend/api/v1/runs.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
# SPDX-License-Identifier: Apache-2.0
33
import asyncio
44
from datetime import datetime
5-
from typing import Annotated
65

76
from asgi_correlation_id import correlation_id
87
from fastapi import APIRouter, Depends, Query
98
from jinja2 import Template
109
from kombu.exceptions import KombuError
1110

12-
from syncmaster.backend.dependencies import Stub
1311
from syncmaster.backend.services import UnitOfWork, get_user
1412
from syncmaster.db.models import RunType, Status, User
1513
from syncmaster.db.utils import Permission
@@ -23,8 +21,8 @@
2321
ReadRunSchema,
2422
RunPageSchema,
2523
)
26-
from syncmaster.settings import Settings
2724
from syncmaster.worker.config import celery
25+
from syncmaster.worker.settings import worker_settings
2826

2927
router = APIRouter(tags=["Runs"], responses=get_error_responses())
3028

@@ -83,7 +81,6 @@ async def read_run(
8381
@router.post("/runs")
8482
async def start_run(
8583
create_run_data: CreateRunSchema,
86-
settings: Annotated[Settings, Depends(Stub(Settings))],
8784
unit_of_work: UnitOfWork = Depends(UnitOfWork),
8885
current_user: User = Depends(get_user(is_active=True)),
8986
) -> ReadRunSchema:
@@ -120,7 +117,7 @@ async def start_run(
120117
type=RunType.MANUAL,
121118
)
122119

123-
log_url = Template(settings.worker.LOG_URL_TEMPLATE).render(
120+
log_url = Template(worker_settings.LOG_URL_TEMPLATE).render(
124121
run=run,
125122
correlation_id=correlation_id.get(),
126123
)

syncmaster/backend/export_openapi_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from fastapi import FastAPI
99

1010
from syncmaster.backend import application_factory
11-
from syncmaster.settings import Settings
11+
from syncmaster.backend.settings import BackendSettings as Settings
1212

1313

1414
def get_openapi_schema(app: FastAPI) -> dict:

syncmaster/backend/middlewares/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from syncmaster.backend.middlewares.request_id import apply_request_id_middleware
1313
from syncmaster.backend.middlewares.session import apply_session_middleware
1414
from syncmaster.backend.middlewares.static_files import apply_static_files
15-
from syncmaster.settings import Settings
15+
from syncmaster.backend.settings import BackendSettings as Settings
1616

1717

1818
def apply_middlewares(

syncmaster/backend/middlewares/cors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi import FastAPI
44
from starlette.middleware.cors import CORSMiddleware
55

6-
from syncmaster.settings.server import CORSSettings
6+
from syncmaster.backend.settings.server import CORSSettings
77

88

99
def apply_cors_middleware(app: FastAPI, settings: CORSSettings) -> FastAPI:

syncmaster/backend/middlewares/monitoring/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from starlette.responses import PlainTextResponse
55
from starlette_exporter import PrometheusMiddleware, handle_metrics
66

7+
from syncmaster.backend.settings.server.monitoring import MonitoringSettings
78
from syncmaster.backend.utils.slug import slugify
8-
from syncmaster.settings.server.monitoring import MonitoringSettings
99

1010
DEFAULT_SKIP_PATHS = {
1111
"/monitoring/metrics",

syncmaster/backend/middlewares/openapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from starlette.requests import Request
1313
from starlette.responses import JSONResponse
1414

15-
from syncmaster.settings.server.openapi import OpenAPISettings
15+
from syncmaster.backend.settings.server.openapi import OpenAPISettings
1616

1717

1818
async def custom_openapi(request: Request) -> JSONResponse:

syncmaster/backend/middlewares/request_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from fastapi import FastAPI
55
from uuid6 import uuid7
66

7-
from syncmaster.settings.server import RequestIDSettings
7+
from syncmaster.backend.settings.server import RequestIDSettings
88

99

1010
def apply_request_id_middleware(app: FastAPI, settings: RequestIDSettings) -> FastAPI:

syncmaster/backend/middlewares/static_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi import FastAPI
44
from fastapi.staticfiles import StaticFiles
55

6-
from syncmaster.settings.server.static_files import StaticFilesSettings
6+
from syncmaster.backend.settings.server.static_files import StaticFilesSettings
77

88

99
def apply_static_files(app: FastAPI, settings: StaticFilesSettings) -> FastAPI:

syncmaster/backend/providers/auth/dummy_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
from syncmaster.backend.dependencies import Stub
1212
from syncmaster.backend.providers.auth.base_provider import AuthProvider
1313
from syncmaster.backend.services import UnitOfWork
14+
from syncmaster.backend.settings.auth.dummy import DummyAuthProviderSettings
1415
from syncmaster.backend.utils.jwt import decode_jwt, sign_jwt
1516
from syncmaster.db.models import User
1617
from syncmaster.exceptions import EntityNotFoundError
1718
from syncmaster.exceptions.auth import AuthorizationError
18-
from syncmaster.settings.auth.dummy import DummyAuthProviderSettings
1919

2020
log = logging.getLogger(__name__)
2121

0 commit comments

Comments
 (0)