Refactor backend services and utilities
- Update service layer implementations - Improve configuration handling utilities - Update documentation tasks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,26 +1,3 @@
|
||||
### T-07 · Break cross-service import: `jail_config_service` imports `jail_service`
|
||||
|
||||
**Where found:** `backend/app/services/jail_config_service.py` — `import app.services.jail_service as jail_service`
|
||||
|
||||
**Why this is needed:** Services at the same layer should not depend on each other. Shared logic should move to a lower-level utility. This creates a dependency cycle risk and makes both services harder to test independently.
|
||||
|
||||
**Goal:** Shared socket operations extracted to `app/utils/` or `app/utils/jail_socket.py`. No service imports a sibling service.
|
||||
|
||||
**What to do:**
|
||||
1. Identify which functions from `jail_service` are called by `jail_config_service`.
|
||||
2. Extract shared low-level socket helpers to `app/utils/jail_socket.py` (or extend `fail2ban_client.py`).
|
||||
3. Update both services to import from the utility layer.
|
||||
|
||||
**Possible traps and issues:**
|
||||
- Some `jail_service` functions that are called may themselves import geo, config, or other services — trace the full dependency graph before extracting.
|
||||
- APScheduler tasks reference `jail_service` — ensure they still work after any reorganisation.
|
||||
|
||||
**Docs changes needed:** `Docs/Architekture.md` — add rule: services must not import sibling services.
|
||||
|
||||
**Doc references:** `Docs/Architekture.md`
|
||||
|
||||
---
|
||||
|
||||
### T-08 · `_SOCKET_TIMEOUT` defined 6× — `constants.py` constant unused
|
||||
|
||||
**Where found:** `backend/app/utils/constants.py:16` (defines `FAIL2BAN_SOCKET_TIMEOUT_SECONDS = 5.0` but is never imported); `ban_service.py` (5.0), `jail_service.py` (10.0), `config_service.py` (10.0), `server_service.py` (10.0), `log_service.py` (10.0), `jail_config_service.py` (10.0), `config_file_utils.py` (10.0)
|
||||
|
||||
Reference in New Issue
Block a user