Add comments to example

This commit is contained in:
asonix 2023-03-22 22:17:41 -05:00
parent fa395efbae
commit 4d4a70d290

View file

@ -28,6 +28,7 @@ pub struct MyJob {
async fn main() -> Result<(), Error> { async fn main() -> Result<(), Error> {
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn")); let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn"));
// Install the metrics subscriber
let stats_handle = background_jobs::metrics::install()?; let stats_handle = background_jobs::metrics::install()?;
tracing_subscriber::fmt::fmt() tracing_subscriber::fmt::fmt()
@ -56,6 +57,7 @@ async fn main() -> Result<(), Error> {
actix_rt::spawn(async move { actix_rt::spawn(async move {
loop { loop {
actix_rt::time::sleep(Duration::from_millis(500)).await; actix_rt::time::sleep(Duration::from_millis(500)).await;
// Get the current stats for the background jobs processor
println!("{:?}", stats_handle.get()); println!("{:?}", stats_handle.get());
} }
}); });