5.4 KiB
Implementation Plan
[Overview]
Remove the DNS Resolution Service background functionality while preserving manual DNS resolution capabilities.
The current DNS system includes both background automatic resolution that runs periodically and manual user-triggered resolution. This implementation will remove all background resolution components including the DNS service lifecycle, caching system, automatic refresh intervals, and service toggle functionality. Manual DNS resolution will be preserved and simplified to work without caching, making DNS resolution purely on-demand when users explicitly trigger it via the refresh DNS action (Ctrl+R).
[Types]
Simplify DNS-related data structures by removing background service state management.
DNSService class modifications:
- Remove
_background_task: Optional[asyncio.Task]
field - Remove
_stop_event: asyncio.Event
field - Remove
_resolution_cache: Dict[str, DNSResolution]
field - Remove
_update_callback: Optional[Callable]
field - Remove
update_interval: int
parameter and field - Keep
enabled: bool
andtimeout: float
for manual resolution control - Remove cache-related methods:
get_cached_resolution()
,clear_cache()
,get_cache_stats()
Configuration type changes:
- Remove
dns_resolution.interval
setting - Remove
dns_resolution.cache_ttl
setting - Keep
dns_resolution.enabled
anddns_resolution.timeout
for manual resolution
[Files]
Remove background DNS service components across multiple files.
Files to be modified:
src/hosts/core/dns.py
- Remove background service, caching, and lifecycle managementsrc/hosts/tui/app.py
- Remove background service initialization and toggle functionalitysrc/hosts/core/config.py
- Remove background resolution configuration optionssrc/hosts/tui/keybindings.py
- Remove DNS service toggle keybindingtests/test_dns.py
- Update tests to reflect manual-only functionalitytests/test_config.py
- Remove tests for background DNS configuration
No new files to be created No files to be deleted
[Functions]
Remove background service functions and simplify DNS resolution interface.
Functions to be removed from DNSService:
start_background_resolution()
- Background service startupstop_background_resolution()
- Background service shutdown_background_worker()
- Background resolution worker loop_resolve_and_cache()
- Background resolution with cachingset_update_callback()
- Callback registration for background updatesget_cached_resolution()
- Cache retrieval methodclear_cache()
- Cache clearing methodget_cache_stats()
- Cache statistics method
Functions to be modified:
__init__()
- Remove update_interval, cache, background task initializationresolve_entry_async()
- Remove cache logic, perform direct resolutionresolve_entry()
- Remove cache logic and background task schedulingrefresh_entry()
- Simplify to direct resolution without cache managementrefresh_all_entries()
- Simplify to direct batch resolution without caching
Functions to be removed from HostsManagerApp:
action_toggle_dns_service()
- DNS service toggle functionality
Configuration functions to be removed:
get_dns_resolution_interval()
- Background interval settingset_dns_resolution_interval()
- Background interval configurationget_dns_cache_ttl()
- Cache TTL setting
[Classes]
Simplify DNSService class by removing background service capabilities.
Modified classes:
- DNSService (src/hosts/core/dns.py):
- Remove background service state management
- Remove caching infrastructure
- Remove callback system for background updates
- Simplify constructor to only accept
enabled
andtimeout
parameters - Keep manual resolution methods:
resolve_entry_async()
,refresh_entry()
,refresh_all_entries()
No new classes to be created No classes to be removed
[Dependencies]
No changes to external dependencies required.
All required dependencies for manual DNS resolution (asyncio, socket) remain unchanged. Background service removal eliminates some asyncio usage but doesn't require dependency modifications.
[Testing]
Update existing DNS tests to focus on manual resolution functionality.
Test modifications required:
- Remove background service lifecycle tests from
TestDNSService
- Remove cache-related tests: cache hit/miss, cache operations, cache stats
- Remove background worker and callback tests
- Keep and update manual resolution tests
- Update configuration tests to remove background DNS settings
- Simplify DNSService initialization tests to reflect new constructor
Test files to modify:
tests/test_dns.py
- Remove ~15 background service and cache teststests/test_config.py
- Remove background DNS configuration tests
[Implementation Order]
Sequential implementation to minimize conflicts and ensure system stability.
- Update DNSService class - Remove background service infrastructure and caching
- Update configuration system - Remove background DNS settings and related methods
- Remove keybinding - Remove DNS service toggle from keybindings
- Update main application - Remove background service initialization and toggle action
- Update tests - Remove background service tests and update remaining tests
- Verify manual DNS resolution - Test that manual refresh functionality still works
- Test complete removal - Ensure no background DNS activity occurs