mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 03:04:03 +00:00
6f2b6268a4
Improve performance when serving /api/state in mock mode by optimizing alert handling and JSON serialization. Changes: - Add UpdateAlertSnapshots() to cache alerts without blocking - Use lazy population of alert snapshots to avoid lock contention - Switch to json.Marshal for better performance with large payloads - Add debug logging to track /api/state performance - Simplify GetState() logic in mock mode Performance improvements: - Eliminates alert manager lock during /api/state requests - Reduces JSON encoding overhead for large mock datasets - Ensures sub-second response times even with 7 nodes and 90+ guests Testing: - Mock mode returns state instantly without blocking - Alert snapshots populate correctly on first request - Debug logs confirm fast execution path
Internal API Package
This directory contains the API server implementation for Pulse.
Important Note About frontend-modern/
The frontend-modern/ subdirectory that appears here is:
- AUTO-GENERATED during builds
- NOT the source code - just a build artifact
- IN .gitignore - never committed
- REQUIRED BY GO - The embed directive needs it here
Frontend Development Location
👉 Edit frontend files at: /opt/pulse/frontend-modern/src/
Why This Structure?
Go's //go:embed directive has limitations:
- Cannot use
../paths to access parent directories - Cannot follow symbolic links
- Must embed files within the Go module
This is a known Go limitation and our structure works around it.