move dirty to crate::utils

This commit is contained in:
Luna Yao
2026-04-18 03:46:43 +02:00
parent 7345acfe7c
commit 84984e1641
6 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::dns::config::DNS_NODE_TTI;
use crate::dns::utils::addr::NameServerAddr;
use crate::dns::utils::dirty::DirtyFlag;
use crate::utils::dirty::DirtyFlag;
use crate::dns::zone::{Zone, ZoneGroup};
use crate::proto::dns::DnsNodeMgrRpc;
use crate::proto::dns::{DnsSnapshot, HeartbeatRequest, HeartbeatResponse};
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::common::PeerId;
use crate::common::global_ctx::ArcGlobalCtx;
use crate::dns::config::{DNS_PEER_TTI, DnsExportConfig, DnsGlobalCtxExt};
use crate::dns::utils::dirty::DirtyFlag;
use crate::utils::dirty::DirtyFlag;
use crate::dns::zone::ZoneGroup;
use crate::peer_center::instance::PeerCenterPeerManagerTrait;
use crate::peers::peer_manager::PeerManager;
-37
View File
@@ -1,37 +0,0 @@
use tokio::sync::watch;
#[derive(Debug)]
pub struct DirtyFlag {
tx: watch::Sender<bool>,
rx: watch::Receiver<bool>,
}
impl DirtyFlag {
pub fn new(value: bool) -> Self {
let (tx, rx) = watch::channel(value);
Self { tx, rx }
}
pub fn mark(&self) {
self.tx.send(true).ok();
}
pub fn peek(&self) -> bool {
*self.tx.borrow()
}
pub fn reset(&self) -> bool {
self.tx.send_replace(false)
}
pub async fn wait(&self) {
let mut rx = self.rx.clone();
let _ = rx.wait_for(|v| *v).await;
}
}
impl Default for DirtyFlag {
fn default() -> Self {
Self::new(true)
}
}
+1 -2
View File
@@ -2,7 +2,6 @@ use hickory_proto::rr::LowerName;
use idna::AsciiDenyList;
pub mod addr;
pub mod dirty;
pub mod response;
pub mod zone_handler;
@@ -37,7 +36,7 @@ pub fn parse(name: &str) -> LowerName {
name
} else {
let sanitized = sanitize(name);
tracing::debug!("invalid hostname: {}, sanitized to: {}", name, sanitized);
tracing::debug!("invalid name: {}, sanitized to: {}", name, sanitized);
sanitized.parse().unwrap_or_default()
}
}