Add online detection CLI command with configurable caching #152
+178
−0
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.
Overview
Adds a new
aignostics system online
CLI command to check network connectivity with intelligent caching to minimize unnecessary network requests.Changes
CLI Command
Added
aignostics system online
command that:Service Method
Implemented
is_online()
method in the system service that:_determine_network_health()
infrastructurehttps://api.ipify.org
(reliable, well-known endpoint)Smart Caching
Implemented efficient caching mechanism to avoid excessive network checks:
AIGNOSTICS_SYSTEM_ONLINE_CACHE_TTL_SECONDS
environment variableTests
Added comprehensive test coverage:
Usage
Basic check
Custom cache TTL
export AIGNOSTICS_SYSTEM_ONLINE_CACHE_TTL_SECONDS=30 aignostics system online
Disable caching
In shell scripts
Technical Details
(is_online, timestamp)
stored at class level_determine_network_health()
method with 5-second timeoutDesign Decisions
_determine_network_health()
which already checks api.ipify.orgFiles Modified
src/aignostics/system/_settings.py
(+9 lines) - Addedonline_cache_ttl_seconds
settingsrc/aignostics/system/_service.py
(+31 lines) - Implementedis_online()
with cachingsrc/aignostics/system/_cli.py
(+16 lines) - Addedonline
CLI commandtests/aignostics/system/service_test.py
(+106 lines) - Service teststests/aignostics/system/cli_test.py
(+16 lines) - CLI testsCloses #[issue-number]
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:
astral.sh
curl -LsSf REDACTED
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.