Expand description
§StartWatcher
§File: Indexing/Background/StartWatcher.rs
§Role in Air Architecture
Provides background task management for the File Indexer service, handling file watching startup and periodic indexing tasks.
§Primary Responsibility
Start and manage background file watcher and periodic indexing tasks for the indexing service.
§Secondary Responsibilities
- File watcher initialization and lifecycle management
- Periodic background re-indexing
- Watcher event debouncing
- Background task cleanup
§Dependencies
External Crates:
notify- File system watchingtokio- Async runtime for background tasks
Internal Modules:
crate::Result- Error handling typecrate::AirError- Error typescrate::ApplicationState::ApplicationState- Application statesuper::super::FileIndexer- Main file indexersuper::WatchFile- File watching operations
§Dependents
Indexing::mod::FileIndexer- Main file indexer implementation
§VSCode Pattern Reference
Inspired by VSCode’s background services in
src/vs/workbench/services/search/common/
§Security Considerations
- Path validation before watching
- Watch path limits enforcement
- Permission checking on watch paths
§Performance Considerations
- Event debouncing prevents excessive re-indexing
- Parallel processing of file changes
- Efficient background task scheduling
§Error Handling Strategy
Background tasks log errors and continue running, ensuring temporary failures don’t stop the indexing service.
§Thread Safety
Background tasks use Arc for shared state and async/await for safe concurrent operations.
Structs§
- Background
Indexer Context - Background indexer context containing shared state
- Watcher
Status - Watcher status information
Functions§
- GetWatcher
Status - Get watcher status
- Start
All - Start all background components (watcher and tasks)
- Start
Background Tasks - Start background tasks for periodic indexing
- Start
Debounce Processor - Start the debounce processor task
- Start
File Watcher - Start file watcher for incremental indexing
- StopAll
- Stop all background components
- Stop
Background Tasks - Stop background tasks
- Stop
File Watcher - Stop file watcher