Skip to content

Commit 09d052d

Browse files
[DOP-19992] - split settings to different classes (#136)
* [DOP-19992] - split settings to different classes * [DOP-19992] - remove importing class WorkerSettings * [DOP-19992] - split settings into ServerAppSettings & WorkerAppSettings & SchedulerSettings & add corresponding configuration documentation * [DOP-19992] - move log_url_template to server_settings
1 parent 4021c03 commit 09d052d

File tree

78 files changed

+392
-216
lines changed

Some content is hidden

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

78 files changed

+392
-216
lines changed

.env.docker

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
TZ=UTC
22
ENV=LOCAL
33

4-
# Debug
4+
# Server Settngs
55
SYNCMASTER__SERVER__DEBUG=true
6+
SYNCMASTER__SERVER__LOG_URL_TEMPLATE=https://grafana.example.com?correlation_id={{ correlation_id }}&run_id={{ run.id }}
67

78
# Logging
89
SYNCMASTER__LOGGING__SETUP=True
910
SYNCMASTER__LOGGING__PRESET=colored
10-
SYNCMASTER__LOG_URL_TEMPLATE=https://grafana.example.com?correlation_id={{ correlation_id }}&run_id={{ run.id }}
11+
12+
# Encrypt / Decrypt credentials data
13+
SYNCMASTER__ENCRYPTION__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
14+
15+
# Scheduler settings
16+
SYNCMASTER__SCHEDULER__TRANSFER_FETCHING_TIMEOUT_SECONDS=200
1117

1218
# Session
1319
SYNCMASTER__SERVER__SESSION__SECRET_KEY=session_secret_key
1420

15-
# Encrypt / Decrypt credentials data
16-
SYNCMASTER__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
17-
1821
# Postgres
1922
SYNCMASTER__DATABASE__URL=postgresql+asyncpg://syncmaster:changeme@db:5432/syncmaster
2023

2124
# TODO: add to KeycloakAuthProvider documentation about creating new realms, add users, etc.
2225
# KEYCLOAK Auth
23-
SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080
24-
SYNCMASTER__AUTH__REALM_NAME=manually_created
25-
SYNCMASTER__AUTH__CLIENT_ID=manually_created
26-
SYNCMASTER__AUTH__CLIENT_SECRET=generated_by_keycloak
27-
SYNCMASTER__AUTH__REDIRECT_URI=http://localhost:8000/v1/auth/callback
28-
SYNCMASTER__AUTH__SCOPE=email
26+
SYNCMASTER__AUTH__KEYCLOAK__SERVER_URL=http://keycloak:8080
27+
SYNCMASTER__AUTH__KEYCLOAK__REALM_NAME=manually_created
28+
SYNCMASTER__AUTH__KEYCLOAK__CLIENT_ID=manually_created
29+
SYNCMASTER__AUTH__KEYCLOAK__CLIENT_SECRET=generated_by_keycloak
30+
SYNCMASTER__AUTH__KEYCLOAK__REDIRECT_URI=http://localhost:8000/auth/callback
31+
SYNCMASTER__AUTH__KEYCLOAK__SCOPE=email
32+
SYNCMASTER__AUTH__KEYCLOAK__VERIFY_SSL=False
2933
SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider
3034

3135
# Dummy Auth

.env.local

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
export TZ=UTC
22
export ENV=LOCAL
33

4-
# Debug
4+
# Server Settngs
55
export SYNCMASTER__SERVER__DEBUG=true
6+
export SYNCMASTER__SERVER__LOG_URL_TEMPLATE="https://grafana.example.com?correlation_id={{ correlation_id }}&run_id={{ run.id }}"
67

78
# Logging
89
export SYNCMASTER__LOGGING__SETUP=True
910
export SYNCMASTER__LOGGING__PRESET=colored
10-
export SYNCMASTER__LOG_URL_TEMPLATE="https://grafana.example.com?correlation_id={{ correlation_id }}&run_id={{ run.id }}"
11+
12+
# Scheduler settings
13+
export SYNCMASTER__SCHEDULER__TRANSFER_FETCHING_TIMEOUT_SECONDS=200
1114

1215
# Session
1316
export SYNCMASTER__SERVER__SESSION__SECRET_KEY=session_secret_key
1417

1518
# Encrypt / Decrypt credentials data
16-
export SYNCMASTER__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
19+
export SYNCMASTER__ENCRYPTION__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
1720

1821
# Postgres
1922
export SYNCMASTER__DATABASE__URL=postgresql+asyncpg://syncmaster:changeme@localhost:5432/syncmaster
2023

2124
# Keycloack Auth
22-
export SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080
23-
export SYNCMASTER__AUTH__REALM_NAME=manually_created
24-
export SYNCMASTER__AUTH__CLIENT_ID=manually_created
25-
export SYNCMASTER__AUTH__CLIENT_SECRET=generated_by_keycloak
26-
export SYNCMASTER__AUTH__REDIRECT_URI=http://localhost:8000/auth/callback
27-
export SYNCMASTER__AUTH__SCOPE=email
25+
export SYNCMASTER__AUTH__KEYCLOAK__SERVER_URL=http://keycloak:8080
26+
export SYNCMASTER__AUTH__KEYCLOAK__REALM_NAME=manually_created
27+
export SYNCMASTER__AUTH__KEYCLOAK__CLIENT_ID=manually_created
28+
export SYNCMASTER__AUTH__KEYCLOAK__CLIENT_SECRET=generated_by_keycloak
29+
export SYNCMASTER__AUTH__KEYCLOAK__REDIRECT_URI=http://localhost:8000/auth/callback
30+
export SYNCMASTER__AUTH__KEYCLOAK__SCOPE=email
31+
export SYNCMASTER__AUTH__KEYCLOAK__VERIFY_SSL=False
2832
export SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider
2933

3034
# Dummy Auth

.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__SERVER__SESSION__SECRET_KEY=session_secret_key SYNCMASTER__BROKER__URL=amqp://fake:faket@fake:5672/ SYNCMASTER__CRYPTO_KEY=crypto_key SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=fakepython python -m syncmaster.backend.scripts.export_openapi_schema docs/_static/openapi.json
20+
- SYNCMASTER__DATABASE__URL=postgresql+psycopg://fake:[email protected]:5432/fake SYNCMASTER__SERVER__SESSION__SECRET_KEY=session_secret_key SYNCMASTER__BROKER__URL=amqp://fake:faket@fake:5672/ SYNCMASTER__ENCRYPTION__CRYPTO_KEY=crypto_key SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=fakepython python -m syncmaster.backend.scripts.export_openapi_schema docs/_static/openapi.json
2121

2222
sphinx:
2323
configuration: docs/conf.py

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ dev-server: db-start ##@Application Run development server (without docker)
113113
${POETRY} run python -m syncmaster.backend $(ARGS)
114114

115115
dev-worker: db-start broker-start ##@Application Run development broker (without docker)
116-
${POETRY} run python -m celery -A syncmaster.worker.config.celery worker --max-tasks-per-child=1 $(ARGS)
116+
${POETRY} run python -m celery -A syncmaster.worker.celery worker --max-tasks-per-child=1 $(ARGS)
117117

118118

119119

docker/Dockerfile.worker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ COPY ./syncmaster/ /app/syncmaster/
3939

4040
FROM base as test
4141

42-
ENV SYNCMASTER__CREATE_SPARK_SESSION_FUNCTION=tests.spark.get_worker_spark_session
42+
ENV SYNCMASTER__WORKER__CREATE_SPARK_SESSION_FUNCTION=tests.spark.get_worker_spark_session
4343

4444
# CI runs tests in the worker container, so we need backend dependencies too
4545
RUN poetry install --no-root --all-extras --with test --without docs,dev

docker/entrypoint_worker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ set -e
55
# Required to start each Celery task in separated process, avoiding issues with global Spark session object
66

77
# exec is required to forward all signals to the main process
8-
exec python -m celery -A syncmaster.worker.config.celery worker --max-tasks-per-child=1 "$@"
8+
exec python -m celery -A syncmaster.worker.celery worker --max-tasks-per-child=1 "$@"
99

docs/backend/configuration/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ Configuration
1818
static_files
1919
openapi
2020

21-
.. autopydantic_settings:: syncmaster.settings.Settings
22-
.. autopydantic_settings:: syncmaster.settings.server.ServerSettings
21+
.. autopydantic_settings:: syncmaster.backend.settings.ServerAppSettings
22+
.. autopydantic_settings:: syncmaster.backend.settings.server.ServerSettings

docs/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
backend/openapi
2121
backend/configuration/index
2222

23+
24+
.. toctree::
25+
:maxdepth: 2
26+
:caption: Worker
27+
:hidden:
28+
29+
worker/configuration/index
30+
31+
32+
.. toctree::
33+
:maxdepth: 2
34+
:caption: Scheduler
35+
:hidden:
36+
37+
scheduler/configuration/index
38+
2339
.. toctree::
2440
:maxdepth: 2
2541
:caption: Development
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. _backend-configuration-broker:
2+
3+
Broker settings
4+
=================
5+
6+
.. autopydantic_model:: syncmaster.settings.broker.RabbitMQSettings
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. _backend-configuration-database:
2+
3+
Database settings
4+
=================
5+
6+
.. autopydantic_model:: syncmaster.settings.database.DatabaseSettings

0 commit comments

Comments
 (0)