pub async fn start_update_scheduler(
bin_name: &str,
current_version: &str,
callback: Box<dyn Fn(UpdateAvailableInfo) + Send + Sync>,
) -> Result<JoinHandle<()>>Expand description
Start the update scheduler
This function starts a background task that periodically checks for updates and sends notifications through a callback when updates are available.
§Arguments
bin_name- Name of the binary (e.g., “terraphim-agent”)current_version- Current version of the binarycallback- Function to call when an update is available
§Returns
Ok(JoinHandle<()>)- Handle to the scheduler task (can be used to abort)Err(anyhow::Error)- Error if scheduler fails to start
§Example
use terraphim_update::start_update_scheduler;
async {
let handle = start_update_scheduler(
"terraphim-agent",
"1.0.0",
Box::new(|update_info| {
println!("Update available: {}", update_info.latest_version);
})
).await?;
};