use std::time::Duration;
use a7n_platform::permissions;
use tokio::sync::oneshot;
use crate::daemon::InputRetried;
const INPUT_RETRY_INTERVAL: Duration = Duration::from_secs(2);
pub(crate) fn spawn(handles: oneshot::Sender<InputRetried>) {
tokio::spawn(retry(handles));
}
async fn retry(mut handles: oneshot::Sender<InputRetried>) {
while !permissions::missing().is_empty() {
tokio::select! {
() = handles.closed() => return,
() = tokio::time::sleep(INPUT_RETRY_INTERVAL) => {}
}
}
let started = a7n_platform::input::start().map_err(|error| {
crate::log::event!("kind=input_retry_stopped reason={error}");
error.to_string()
});
let _ = handles.send(started);
}