feat(readarr): add the Readarr health check network call

Inhabit ReadarrEvent with its first variant, HealthCheck, mapped to
GET /health, and add get_readarr_healthcheck alongside the equivalent
Lidarr, Radarr, and Sonarr fetchers. The call is internal only and has
no CLI surface, matching the other three servarrs; it exists so that an
unreachable instance surfaces an error banner on tick.

The healthcheck fetcher lives in readarr_network/mod.rs rather than a
submodule, so its tests live in readarr_network_tests.rs next to the
resource() and NetworkEvent conversion tests, mirroring Lidarr.

MockServarrApi::build_for matched NetworkEvent by value with no Radarr
fallback arm. It compiled only while ReadarrEvent was uninhabited and
no value could reach it; the first variant makes the match non
exhaustive, so it now assigns the config to the Readarr server tab.
This commit is contained in:
Dark-Alex-17 committed 2026-08-20 15:44:07 -06:00
1 parent 29f043f5c7
commit cd341c3d71
3 files changed
+87 -4

No files matched your search

+33 -4
View File
@@ -1,15 +1,24 @@
use anyhow::Result;
use log::info;
use super::{NetworkEvent, NetworkResource};
use crate::models::readarr_models::ReadarrSerdeable;
use crate::network::Network;
use crate::network::{Network, RequestMethod};
#[cfg(test)]
#[path = "readarr_network_tests.rs"]
mod readarr_network_tests;
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum ReadarrEvent {}
pub enum ReadarrEvent {
HealthCheck,
}
impl NetworkResource for ReadarrEvent {
fn resource(&self) -> &'static str {
match *self {}
match &self {
ReadarrEvent::HealthCheck => "/health",
}
}
}
@@ -24,6 +33,26 @@ impl Network<'_, '_> {
&mut self,
readarr_event: ReadarrEvent,
) -> Result<ReadarrSerdeable> {
match readarr_event {}
match readarr_event {
ReadarrEvent::HealthCheck => self
.get_readarr_healthcheck()
.await
.map(ReadarrSerdeable::from),
}
}
pub(in crate::network::readarr_network) async fn get_readarr_healthcheck(
&mut self,
) -> Result<()> {
info!("Performing Readarr health check");
let event = ReadarrEvent::HealthCheck;
let request_props = self
.request_props_from(event, RequestMethod::Get, None::<()>, None, None)
.await;
self
.handle_request::<(), ()>(request_props, |_, _| ())
.await
}
}