pub struct ConnectivityMonitor {
server_url: Arc<RwLock<Option<String>>>,
http_client: Arc<HttpClient>,
reporter: ConnectivityReporter,
is_monitoring: Arc<AtomicBool>,
}Expand description
Connectivity monitor for tracking server reachability.
Reachability is driven primarily by real repository traffic via the shared
ConnectivityReporter. The monitor itself only runs an offline recovery
probe (see start_monitoring) and serves the connectivity Tauri commands.
Fields§
§server_url: Arc<RwLock<Option<String>>>§http_client: Arc<HttpClient>§reporter: ConnectivityReporter§is_monitoring: Arc<AtomicBool>Implementations§
Source§impl ConnectivityMonitor
impl ConnectivityMonitor
Sourcepub fn new(http_client: HttpClient) -> Self
pub fn new(http_client: HttpClient) -> Self
Create a new connectivity monitor
Sourcepub fn set_app_handle(&mut self, app_handle: AppHandle)
pub fn set_app_handle(&mut self, app_handle: AppHandle)
Set the Tauri app handle for event emission. Must be called before the reporter is shared with the repository.
Sourcepub fn reporter(&self) -> ConnectivityReporter
pub fn reporter(&self) -> ConnectivityReporter
Get a cheap, cloneable reporter so the repository can feed server outcomes into the same reachability state the UI observes.
Sourcepub async fn set_server_url(&self, url: String)
pub async fn set_server_url(&self, url: String)
Update the server URL
Sourcepub async fn get_status(&self) -> ConnectivityStatus
pub async fn get_status(&self) -> ConnectivityStatus
Get current connectivity status
Sourcepub async fn check_reachability(&self) -> bool
pub async fn check_reachability(&self) -> bool
Deliberately probe the server’s reachability (manual check / recovery probe). The result is applied immediately (no debounce) since this is an explicit test.
Sourcepub async fn mark_reachable(&self)
pub async fn mark_reachable(&self)
Mark server as reachable (called after successful API call / login)
Sourcepub async fn mark_unreachable(&self, error: Option<String>)
pub async fn mark_unreachable(&self, error: Option<String>)
Mark server as unreachable directly.
Used by deliberate signals (e.g. a failed login/connect) where the caller
knows the server is unreachable now. Repository traffic should prefer
reporter().report_network_failure() so the debounce applies.
Sourcepub async fn start_monitoring(&self)
pub async fn start_monitoring(&self)
Start the offline recovery probe.
While online, reachability is kept fresh by real traffic, so the probe
idles. While offline, it polls /System/Info/Public every
RETRY_CHECK_INTERVAL_MS to detect the server returning even when no user
traffic is flowing.
Sourcepub fn stop_monitoring(&self)
pub fn stop_monitoring(&self)
Stop monitoring connectivity