mirror of
https://github.com/SeriousBug/gandi-live-dns-rust
synced 2024-05-18 03:09:04 -05:00
Use async sleep when long running
Using an async sleep just seems more appropriate as we are in an async context, although the results are identical since gandi-live-dns only uses a single thread.
This commit is contained in:
parent
041c1109e0
commit
ec8f12880e
|
@ -6,7 +6,7 @@ use config::IPSourceName;
|
||||||
use ip_source::icanhazip::IPSourceIcanhazip;
|
use ip_source::icanhazip::IPSourceIcanhazip;
|
||||||
use reqwest::{header, Client, ClientBuilder, StatusCode};
|
use reqwest::{header, Client, ClientBuilder, StatusCode};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::thread;
|
use tokio::time::sleep;
|
||||||
use std::{num::NonZeroU32, sync::Arc, time::Duration};
|
use std::{num::NonZeroU32, sync::Arc, time::Duration};
|
||||||
use tokio::{self, task::JoinHandle};
|
use tokio::{self, task::JoinHandle};
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -126,7 +126,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
if let Some(delay) = opts.repeat {
|
if let Some(delay) = opts.repeat {
|
||||||
loop {
|
loop {
|
||||||
run_dispatch(&conf).await.ok();
|
run_dispatch(&conf).await.ok();
|
||||||
thread::sleep(Duration::from_secs(delay))
|
sleep(Duration::from_secs(delay)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise run just once
|
// otherwise run just once
|
||||||
|
|
Loading…
Reference in a new issue