refactor config
This commit is contained in:
@@ -6,13 +6,14 @@ use async_trait::async_trait;
|
||||
use libc::{c_double, c_int, timeval};
|
||||
use tokio::select;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::{debug, warn};
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::{ChimemonMessage, ChimemonTarget, ChimemonTargetChannel, ChronySockConfig};
|
||||
use crate::{ChimemonMessage, ChimemonTarget, ChimemonTargetChannel, config::ChronySockConfig};
|
||||
|
||||
const CHRONY_MAGIC: c_int = 0x534f434b;
|
||||
|
||||
pub struct ChronySockServer {
|
||||
name: String,
|
||||
sock_path: PathBuf,
|
||||
}
|
||||
|
||||
@@ -27,17 +28,19 @@ pub struct ChronyTimeReport {
|
||||
magic: c_int,
|
||||
}
|
||||
|
||||
impl ChronySockServer {
|
||||
pub fn new(config: ChronySockConfig) -> Self {
|
||||
ChronySockServer {
|
||||
sock_path: config.sock.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ChronySockServer {}
|
||||
|
||||
#[async_trait]
|
||||
impl ChimemonTarget for ChronySockServer {
|
||||
type Config = ChronySockConfig;
|
||||
fn new(name: &str, config: ChronySockConfig) -> Self {
|
||||
ChronySockServer {
|
||||
name: name.to_owned(),
|
||||
sock_path: config.sock.into(),
|
||||
}
|
||||
}
|
||||
async fn run(mut self, mut chan: ChimemonTargetChannel, cancel: CancellationToken) {
|
||||
info!("Chrony refclock task started");
|
||||
loop {
|
||||
select! {
|
||||
_ = cancel.cancelled() => { return }
|
||||
|
||||
Reference in New Issue
Block a user