From 603c6dc116fd022a95c90eb47cb64ce8a9d4e0da Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Tue, 27 Apr 2021 11:16:28 +0300 Subject: [PATCH] noc-agent: Refactor zk module into config --- rust/agent/src/agent.rs | 3 ++- rust/agent/src/collectors/base.rs | 2 +- rust/agent/src/collectors/cpu/collector.rs | 2 +- rust/agent/src/collectors/dns/collector.rs | 2 +- rust/agent/src/collectors/fs/collector.rs | 2 +- rust/agent/src/collectors/memory/collector.rs | 2 +- rust/agent/src/collectors/network/collector.rs | 2 +- rust/agent/src/collectors/registry.rs | 2 +- rust/agent/src/collectors/test/collector.rs | 2 +- rust/agent/src/collectors/twamp_reflector/collector.rs | 2 +- rust/agent/src/collectors/twamp_sender/collector.rs | 2 +- rust/agent/src/collectors/uptime/collector.rs | 2 +- rust/agent/src/{zk.rs => config/config.rs} | 0 rust/agent/src/config/mod.rs | 2 ++ rust/agent/src/config/parser/base.rs | 2 +- rust/agent/src/config/parser/json/base.rs | 2 +- rust/agent/src/config/parser/yaml/base.rs | 2 +- rust/agent/src/config/reader/base.rs | 2 +- rust/agent/src/config/reader/file/base.rs | 2 +- rust/agent/src/config/resolver/base.rs | 2 +- rust/agent/src/config/resolver/zk/base.rs | 2 +- rust/agent/src/lib.rs | 1 - 22 files changed, 22 insertions(+), 20 deletions(-) rename rust/agent/src/{zk.rs => config/config.rs} (100%) diff --git a/rust/agent/src/agent.rs b/rust/agent/src/agent.rs index 9cc9b1d5bd..d8040a7c69 100644 --- a/rust/agent/src/agent.rs +++ b/rust/agent/src/agent.rs @@ -8,14 +8,15 @@ use crate::cli::CliArgs; use crate::collectors::{Collectors, Runnable}; use crate::config::{ConfigResolver, Reader, Resolver}; +use crate::config::{ZkConfig, ZkConfigCollector}; use crate::error::AgentError; -use crate::zk::{ZkConfig, ZkConfigCollector}; use std::collections::HashMap; use std::convert::TryFrom; use std::sync::Arc; use tokio::{runtime::Runtime, task::JoinHandle}; pub struct RunningCollector { + #[allow(dead_code)] collector: Arc, handle: JoinHandle<()>, } diff --git a/rust/agent/src/collectors/base.rs b/rust/agent/src/collectors/base.rs index 6486e94660..7372166708 100644 --- a/rust/agent/src/collectors/base.rs +++ b/rust/agent/src/collectors/base.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use async_trait::async_trait; use enum_dispatch::enum_dispatch; use rand::Rng; diff --git a/rust/agent/src/collectors/cpu/collector.rs b/rust/agent/src/collectors/cpu/collector.rs index 85126b4c0f..642e43e9d2 100644 --- a/rust/agent/src/collectors/cpu/collector.rs +++ b/rust/agent/src/collectors/cpu/collector.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/dns/collector.rs b/rust/agent/src/collectors/dns/collector.rs index 092a7a2beb..e54a22ac44 100644 --- a/rust/agent/src/collectors/dns/collector.rs +++ b/rust/agent/src/collectors/dns/collector.rs @@ -6,9 +6,9 @@ // --------------------------------------------------------------------- use crate::collectors::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; use crate::timing::Timing; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/fs/collector.rs b/rust/agent/src/collectors/fs/collector.rs index f827982a39..1ec6bff7f8 100644 --- a/rust/agent/src/collectors/fs/collector.rs +++ b/rust/agent/src/collectors/fs/collector.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/memory/collector.rs b/rust/agent/src/collectors/memory/collector.rs index f9d3869694..d9f233b897 100644 --- a/rust/agent/src/collectors/memory/collector.rs +++ b/rust/agent/src/collectors/memory/collector.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/network/collector.rs b/rust/agent/src/collectors/network/collector.rs index c81f709a9c..0678cb60d0 100644 --- a/rust/agent/src/collectors/network/collector.rs +++ b/rust/agent/src/collectors/network/collector.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/registry.rs b/rust/agent/src/collectors/registry.rs index 3d18ed6508..5fb35aa449 100644 --- a/rust/agent/src/collectors/registry.rs +++ b/rust/agent/src/collectors/registry.rs @@ -14,8 +14,8 @@ use super::twamp_reflector::{TwampReflectorCollector, TwampReflectorConfig}; use super::twamp_sender::{TwampSenderCollector, TwampSenderConfig}; use super::uptime::{UptimeCollector, UptimeConfig}; use super::Runnable; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use enum_dispatch::enum_dispatch; use serde::Deserialize; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/test/collector.rs b/rust/agent/src/collectors/test/collector.rs index 6566c90027..43d58e541d 100644 --- a/rust/agent/src/collectors/test/collector.rs +++ b/rust/agent/src/collectors/test/collector.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/collectors/twamp_reflector/collector.rs b/rust/agent/src/collectors/twamp_reflector/collector.rs index ccd394ab69..34c60ebdac 100644 --- a/rust/agent/src/collectors/twamp_reflector/collector.rs +++ b/rust/agent/src/collectors/twamp_reflector/collector.rs @@ -5,6 +5,7 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{CollectorConfig, Id, Runnable}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; use crate::proto::connection::Connection; use crate::proto::twamp::{ @@ -12,7 +13,6 @@ use crate::proto::twamp::{ StartSessions, StopSessions, TestRequest, TestResponse, DEFAULT_COUNT, MODE_UNAUTHENTICATED, }; use crate::proto::udp::UdpConnection; -use crate::zk::ZkConfigCollector; use agent_derive::Id; use async_trait::async_trait; use bytes::Bytes; diff --git a/rust/agent/src/collectors/twamp_sender/collector.rs b/rust/agent/src/collectors/twamp_sender/collector.rs index 0e629e1932..99bcc0c3f4 100644 --- a/rust/agent/src/collectors/twamp_sender/collector.rs +++ b/rust/agent/src/collectors/twamp_sender/collector.rs @@ -6,6 +6,7 @@ // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; use crate::proto::connection::Connection; use crate::proto::frame::{FrameReader, FrameWriter}; @@ -17,7 +18,6 @@ use crate::proto::twamp::{ MODE_UNAUTHENTICATED, }; use crate::timing::Timing; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use bytes::{Bytes, BytesMut}; diff --git a/rust/agent/src/collectors/uptime/collector.rs b/rust/agent/src/collectors/uptime/collector.rs index 038a8d446f..8509d42006 100644 --- a/rust/agent/src/collectors/uptime/collector.rs +++ b/rust/agent/src/collectors/uptime/collector.rs @@ -5,8 +5,8 @@ // See LICENSE for details // --------------------------------------------------------------------- use super::super::{Collectable, CollectorConfig, Id, Repeatable, Status}; +use crate::config::ZkConfigCollector; use crate::error::AgentError; -use crate::zk::ZkConfigCollector; use agent_derive::{Id, Repeatable}; use async_trait::async_trait; use std::convert::TryFrom; diff --git a/rust/agent/src/zk.rs b/rust/agent/src/config/config.rs similarity index 100% rename from rust/agent/src/zk.rs rename to rust/agent/src/config/config.rs diff --git a/rust/agent/src/config/mod.rs b/rust/agent/src/config/mod.rs index 12177af38d..a14ff9f752 100644 --- a/rust/agent/src/config/mod.rs +++ b/rust/agent/src/config/mod.rs @@ -5,10 +5,12 @@ // See LICENSE for details // --------------------------------------------------------------------- +pub mod config; pub mod parser; pub mod reader; pub mod resolver; +pub use config::{ZkConfig, ZkConfigCollector}; pub use parser::{ConfigParser, Parser}; pub use reader::{ConfigReader, Reader}; pub use resolver::{ConfigResolver, Resolver}; diff --git a/rust/agent/src/config/parser/base.rs b/rust/agent/src/config/parser/base.rs index 7da211b178..b5d7df0f4d 100644 --- a/rust/agent/src/config/parser/base.rs +++ b/rust/agent/src/config/parser/base.rs @@ -7,8 +7,8 @@ use super::JsonParser; use super::YamlParser; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; pub enum ConfigParser { Json(JsonParser), diff --git a/rust/agent/src/config/parser/json/base.rs b/rust/agent/src/config/parser/json/base.rs index cab4ed2cbb..2d935a3196 100644 --- a/rust/agent/src/config/parser/json/base.rs +++ b/rust/agent/src/config/parser/json/base.rs @@ -6,8 +6,8 @@ // --------------------------------------------------------------------- use super::super::Parser; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; pub struct JsonParser; diff --git a/rust/agent/src/config/parser/yaml/base.rs b/rust/agent/src/config/parser/yaml/base.rs index dd979b552a..72ed73a66d 100644 --- a/rust/agent/src/config/parser/yaml/base.rs +++ b/rust/agent/src/config/parser/yaml/base.rs @@ -6,8 +6,8 @@ // --------------------------------------------------------------------- use super::super::Parser; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; pub struct YamlParser; diff --git a/rust/agent/src/config/reader/base.rs b/rust/agent/src/config/reader/base.rs index 0d1674e20b..d092c1e608 100644 --- a/rust/agent/src/config/reader/base.rs +++ b/rust/agent/src/config/reader/base.rs @@ -6,8 +6,8 @@ // --------------------------------------------------------------------- use super::FileReader; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; use async_trait::async_trait; use enum_dispatch::enum_dispatch; diff --git a/rust/agent/src/config/reader/file/base.rs b/rust/agent/src/config/reader/file/base.rs index 52897511ba..59210a3fe6 100644 --- a/rust/agent/src/config/reader/file/base.rs +++ b/rust/agent/src/config/reader/file/base.rs @@ -7,8 +7,8 @@ use super::super::Reader; use crate::config::ConfigParser; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; use async_trait::async_trait; use std::fs; use std::path::Path; diff --git a/rust/agent/src/config/resolver/base.rs b/rust/agent/src/config/resolver/base.rs index 2ee343a362..ff3ba59856 100644 --- a/rust/agent/src/config/resolver/base.rs +++ b/rust/agent/src/config/resolver/base.rs @@ -8,8 +8,8 @@ use super::{StaticResolver, ZkResolver}; use crate::cli::CliArgs; use crate::config::ConfigReader; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; use async_trait::async_trait; use enum_dispatch::enum_dispatch; use std::convert::TryFrom; diff --git a/rust/agent/src/config/resolver/zk/base.rs b/rust/agent/src/config/resolver/zk/base.rs index 64450edb23..9cbaab707b 100644 --- a/rust/agent/src/config/resolver/zk/base.rs +++ b/rust/agent/src/config/resolver/zk/base.rs @@ -8,8 +8,8 @@ use super::super::Resolver; use crate::cli::CliArgs; use crate::config::reader::ConfigReader; +use crate::config::ZkConfig; use crate::error::AgentError; -use crate::zk::ZkConfig; use async_trait::async_trait; use std::convert::TryFrom; use std::fs; diff --git a/rust/agent/src/lib.rs b/rust/agent/src/lib.rs index 84fe60f682..28a3ad73b8 100644 --- a/rust/agent/src/lib.rs +++ b/rust/agent/src/lib.rs @@ -12,4 +12,3 @@ pub mod config; pub mod error; pub mod proto; pub mod timing; -pub mod zk; -- GitLab