Files
ware_house/docs/flows/async_db_flow.md
2026-03-31 19:15:33 +02:00

40 lines
1.0 KiB
Markdown

# Infrastruttura Async / DB
## Scopo
Questo diagramma descrive il flusso comune usato da tutti i moduli GUI quando
eseguono una query sul database.
## Flusso trasversale
```{mermaid}
flowchart TD
A["Evento UI (click / selezione / ricerca)"] --> B["Metodo finestra"]
B --> C["AsyncRunner.run(awaitable)"]
C --> D["Coroutines sul loop globale"]
D --> E["AsyncMSSQLClient.query_json() / exec()"]
E --> F["SQL Server"]
F --> G["Risultato query"]
G --> H["Future completata"]
H --> I["Callback _ok / _err su thread Tk"]
I --> J["Aggiornamento widget"]
```
## Relazioni principali
```{mermaid}
flowchart LR
Main["main.py"] --> Loop["get_global_loop()"]
Main --> DB["AsyncMSSQLClient"]
Windows["Moduli GUI"] --> Runner["AsyncRunner"]
Runner --> Loop
Runner --> DB
DB --> SQL["SQL Server Mediseawall"]
```
## Note
- Il loop asincrono è condiviso tra tutte le finestre.
- Il client DB è condiviso e creato una sola volta nel launcher.
- I callback che aggiornano la UI rientrano sempre sul thread Tk.