Draft
Expose local HTTP/Unix socket API for real-time monitoring stats#52
Conversation
Co-authored-by: rbas <122783+rbas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Expose local HTTP/Unix socket API for real-time monitoring stats
Expose local HTTP/Unix socket API for real-time monitoring stats
Sep 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a comprehensive local API system that exposes real-time monitoring statistics via both HTTP and Unix socket endpoints. The implementation enables building Terminal UI (TUI) applications and web interfaces while maintaining Fluxa's lightweight architecture.
Key Features
Real-time Monitoring API:
/api/services- List all monitored services with comprehensive stats/api/services/{id}- Get individual service details (by index or URL)Comprehensive Service Statistics:
Enhanced Configuration:
Implementation Details
The solution follows SOLID principles and uses idiomatic Rust patterns:
Arc<RwLock<MonitoringState>>enables real-time data sharing between monitoring tasks and API serverMonitoredServicewithServiceInfoandMonitoringStatsstructs that serialize cleanly to JSONAPI Usage Examples
HTTP API:
Unix Socket API:
Response Format:
{ "services": [{ "url": "https://example.com", "interval_seconds": 300, "max_retries": 3, "retry_interval_seconds": 5, "stats": { "status": "Healthy", "last_response_time_ms": 150, "last_check_timestamp": 1672531200, "next_check_timestamp": 1672531500, "last_error": null, "current_retry_count": 0 } }], "total_count": 1 }Testing
Added comprehensive test coverage including:
All existing functionality remains unchanged and backward compatible.
Fixes #51.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.pushover.nettarget/debug/fluxa --config config.test.toml(dns block)target/debug/fluxa --config demo-config.toml(dns block)httpbin.orgtarget/debug/fluxa --config config.test.toml(dns block)target/debug/fluxa --config demo-config.toml(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.