Skip to content

Commit 6824462

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

File tree

69 files changed

+219
-199
lines changed

Some content is hidden

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

69 files changed

+219
-199
lines changed

.env.docker

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ ENV=LOCAL
44
# Debug
55
SYNCMASTER__SERVER__DEBUG=true
66

7-
# Logging Backend
8-
SYNCMASTER__SERVER__LOGGING__SETUP=True
9-
SYNCMASTER__SERVER__LOGGING__PRESET=colored
10-
11-
# Logging Worker
12-
SYNCMASTER__WORKER__LOGGING__SETUP=True
13-
SYNCMASTER__WORKER__LOGGING__PRESET=json
7+
# TODO: split to backend and worker loggins
8+
# Logging
9+
SYNCMASTER__LOGGING__SETUP=True
10+
SYNCMASTER__LOGGING__PRESET=colored
1411

1512
# Encrypt / Decrypt credentials data
1613
SYNCMASTER__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build:
1717
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --no-root --all-extras --with docs --without dev,test
1818
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry show -v
1919
- python -m pip list -v
20-
- SYNCMASTER__DATABASE__URL=postgresql+psycopg://fake:[email protected]:5432/fake SYNCMASTER__BROKER__URL=amqp://fake:faket@fake:5672/ python -m syncmaster.backend.export_openapi_schema docs/_static/openapi.json
20+
- SYNCMASTER__DATABASE__URL=postgresql+psycopg://fake:[email protected]:5432/fake SYNCMASTER__BROKER__URL=amqp://fake:faket@fake:5672/ SYNCMASTER__CRYPTO_KEY=crypto_key python -m syncmaster.backend.export_openapi_schema docs/_static/openapi.json
2121

2222
sphinx:
2323
configuration: docs/conf.py

docker-compose.test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,4 @@ services:
198198
volumes:
199199
postgres_test_data:
200200
rabbitmq_test_data:
201+
keycloak_data:

poetry.lock

Lines changed: 49 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ worker = [
110110
"uuid6",
111111
"coloredlogs",
112112
"python-json-logger",
113+
"python-keycloak",
113114
]
114115

115116
scheduler = [

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: 3 additions & 3 deletions
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(
@@ -21,8 +21,8 @@ def apply_middlewares(
2121
) -> FastAPI:
2222
"""Add middlewares to the application."""
2323

24-
if settings.server.logging.setup:
25-
setup_logging(settings.server.logging.get_log_config_path())
24+
if settings.logging.setup:
25+
setup_logging(settings.logging.get_log_config_path())
2626

2727
apply_cors_middleware(application, settings.server.cors)
2828
apply_monitoring_metrics_middleware(application, settings.server.monitoring)

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:

0 commit comments

Comments
 (0)