Skip to content

Commit

Permalink
go on
Browse files Browse the repository at this point in the history
  • Loading branch information
devillove084 committed Sep 16, 2023
1 parent a714019 commit f789f77
Show file tree
Hide file tree
Showing 98 changed files with 2,599 additions and 412 deletions.
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ edition = "2021"

[dependencies]
regex = "1.8.1"
toml = "0.7.4"
anyhow = "1.0.71"
multimap = "0.9.0"
async-trait = "0.1.68"
hashed_wheel_timer = "0.1.1"
petgraph = "0.6.3"
dyn-clone = "1.0.11"
clap = { version = "4.3.0", features = ["derive", "string"] }
axum = "0.6.18"
log = "0.4.18"
env_logger = "0.10.0"
tokio = { version = "1.28.1", features = ["full"] }
bytes = { version = "1", features = ["serde"] }
bytes = { version = "1", features = ["serde"] }
130 changes: 130 additions & 0 deletions src/common/configuration/configuration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
use std::{
collections::{HashMap, HashSet},
todo,
};

use hashed_wheel_timer::WheelTimer;

use super::{
configuration_entry::ConfigurationEntry,
provider::{
map_provider::MapProvider, provider_factory::ProviderFactory,

Check warning on line 11 in src/common/configuration/configuration.rs

View workflow job for this annotation

GitHub Actions / Run tests (ubuntu-latest)

unused import: `map_provider::MapProvider`

Check warning on line 11 in src/common/configuration/configuration.rs

View workflow job for this annotation

GitHub Actions / Run tests (macos-latest)

unused import: `map_provider::MapProvider`
secret_provider::SecretProvider, Provider,
},
};

pub const CONFIG_PROVIDER_KEY: &str = "config.providers";
pub const CONFIG_PROVIDERS_DEFAULT: &str =
"PropertiesFile,Environment,SystemProperties,CommandLine,RuntimeOverride";
pub const CONFIG_PROVIDERS_REX: &str = r"^[\w+\d+,\/\.:\|\\\- ]+$";

pub const PLUGIN_DIRECTORY_KEY: &str = "config.plugin.path";
pub const PLUGIN_DIRECTORY_REX: &str = r"^[\w+\d+\/\.\\:\-]+$";

pub const CONFIG_RELOAD_INTERVAL_KEY: &str = "config.reload.interval";

pub struct Configuration {
merged_config: HashMap<String, ConfigurationEntry>,
providers: Vec<Box<dyn Provider>>,
secret_providers: HashMap<String, Box<dyn SecretProvider>>,
provider_config: String,
provider_path: String,
factories: Vec<Box<dyn ProviderFactory>>,
reload_keys: HashSet<String>,
timer: WheelTimer,
}

impl Clone for Configuration {
fn clone(&self) -> Self {
todo!()
}
}

impl Configuration {
pub fn new() -> Self {
let timer = WheelTimer::new(0, 0).unwrap();

Configuration {
merged_config: HashMap::new(),
providers: Vec::new(),
secret_providers: HashMap::new(),
provider_config: "".to_string(),
provider_path: "".to_string(),
factories: Vec::new(),
reload_keys: HashSet::new(),
timer,
}
}

pub fn get_port(&self) -> i32 {
todo!()
}

pub fn get_ssl_port(&self) -> i32 {
todo!()
}

pub fn get_bind(&self) -> String {
todo!()
}

pub fn get_root(&self) -> String {
todo!()
}

pub fn get_load_plugins(&self) -> bool {
todo!()
}

pub fn has_property(&self, key: String) -> bool {
if key.is_empty() {
// TODO: Exception, key cannot be null or empty
return false;
}
match self.merged_config.get(&key) {
Some(e) => return e.schema().is_null(),
None => return false,
}
}

pub fn register_by_string_value(
&self,
key: String,
default_value: String,
is_dynamic: bool,
description: String,
) {
todo!()
}

pub fn register_by_bool_value(
&self,
key: String,
default_value: bool,
is_dynamic: bool,
description: String,
) {
todo!()
}

pub fn register_by_int_value(
&self,
key: String,
default_value: i32,
is_dynamic: bool,
description: String,
) {
todo!()
}

pub fn get_int(&self, key: String) -> i32 {
todo!()
}

// pub async fn new_configuration_with_map_provider(
// &self,
// cli_args: Vec<String>,
// map_provider: MapProvider,
// ) -> Self { todo!()
// }
}
10 changes: 8 additions & 2 deletions src/common/configuration/configuration_entry.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::HashSet;

use super::{
configuration_callback::ConfigurationCallback,
configuration::Configuration, configuration_callback::ConfigurationCallback,
configuration_entry_schema::ConfigurationEntrySchema,
configuration_override::ConfigurationOverride, Configuration,
configuration_override::ConfigurationOverride,
};

pub(crate) struct ConfigurationEntry {
Expand All @@ -12,3 +12,9 @@ pub(crate) struct ConfigurationEntry {
settings: Vec<ConfigurationOverride>,
callbacks: HashSet<Box<dyn ConfigurationCallback>>,
}

impl ConfigurationEntry {
pub fn schema(&self) -> &ConfigurationEntrySchema {
&self.schema
}
}
8 changes: 7 additions & 1 deletion src/common/configuration/configuration_entry_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::configuration_value_validator::ConfigurationValueValidator;

pub(crate) struct ConfigurationEntrySchema {
key: String,
//typ: T,
// typ: T,
source: String,
description: String,
validator: Box<dyn ConfigurationValueValidator>,
Expand All @@ -13,3 +13,9 @@ pub(crate) struct ConfigurationEntrySchema {
help_level: String,
meta: String,
}

impl ConfigurationEntrySchema {
pub fn is_null(&self) -> bool {
todo!()
}
}
57 changes: 1 addition & 56 deletions src/common/configuration/mod.rs
Original file line number Diff line number Diff line change
@@ -1,63 +1,8 @@
use std::{
collections::{HashMap, HashSet},
todo,
};

use hashed_wheel_timer::WheelTimer;

use self::{
configuration_entry::ConfigurationEntry,
provider::{
map_provider::MapProvider, provider_factory::ProviderFactory,
secret_provider::SecretProvider, Provider,
},
};

pub mod configuration;
pub mod configuration_callback;
pub mod configuration_entry;
pub mod configuration_entry_schema;
pub mod configuration_override;
pub mod configuration_value_validator;
pub mod error;
pub mod provider;

pub const CONFIG_PROVIDER_KEY: &str = "config.providers";
pub const CONFIG_PROVIDERS_DEFAULT: &str =
"PropertiesFile,Environment,SystemProperties,CommandLine,RuntimeOverride";
pub const CONFIG_PROVIDERS_REX: &str = r"^[\w+\d+,\/\.:\|\\\- ]+$";

pub const PLUGIN_DIRECTORY_KEY: &str = "config.plugin.path";
pub const PLUGIN_DIRECTORY_REX: &str = r"^[\w+\d+\/\.\\:\-]+$";

pub const CONFIG_RELOAD_INTERVAL_KEY: &str = "config.reload.interval";

pub(crate) struct Configuration {
merged_config: HashMap<String, ConfigurationEntry>,
providers: Vec<Box<dyn Provider>>,
secret_providers: HashMap<String, Box<dyn SecretProvider>>,
provider_config: String,
provider_path: String,
factories: Vec<Box<dyn ProviderFactory>>,
reload_keys: HashSet<String>,
timer: WheelTimer,
}

impl Clone for Configuration {
fn clone(&self) -> Self {
todo!()
}
}

impl Configuration {
pub async fn new_configuration(&self, properties: HashMap<String, String>) -> Self {
todo!()
}

pub async fn new_configuration_with_map_provider(
&self,
cli_args: Vec<String>,
map_provider: MapProvider,
) -> Self {
todo!()
}
}
3 changes: 1 addition & 2 deletions src/common/configuration/provider/provider_factory.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use hashed_wheel_timer::WheelTimer;

use crate::common::configuration::Configuration;

use super::Provider;
use crate::common::configuration::configuration::Configuration;

#[async_trait::async_trait]
pub(crate) trait ProviderFactory {
Expand Down
3 changes: 1 addition & 2 deletions src/common/configuration/provider/secret_provider.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use bytes::Bytes;
use hashed_wheel_timer::WheelTimer;

use crate::common::configuration::Configuration;

use super::provider_factory::ProviderFactory;
use crate::common::configuration::configuration::Configuration;

#[async_trait::async_trait]
pub(crate) trait SecretProvider {
Expand Down
2 changes: 1 addition & 1 deletion src/common/core/base_tsdb_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl TSDBPlugin for BaseTSDBPlugin {
self.id.clone()
}

fn typ(&self) -> String {
fn get_type(&self) -> String {
todo!()
}

Expand Down
15 changes: 6 additions & 9 deletions src/common/core/registry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use dyn_clone::{clone_trait_object, DynClone};

use crate::{
Expand All @@ -14,15 +16,14 @@ use crate::{
},
core::pool::shared_obj::SharedObject,
};
use std::collections::HashMap;

#[async_trait::async_trait]
pub(crate) trait Registry: DynClone {
async fn initialize(&self, load_plugins: bool);

async fn cleanup_pool(&self) -> ExecutorService;

async fn register_plugin(&self, id: String, plugin: Box<dyn TSDBPlugin>);
async fn register_plugin(&self, id: String, plugin: Box<dyn TSDBPlugin + Send>);

fn get_default_plugin(&self) -> Box<dyn TSDBPlugin>;

Expand Down Expand Up @@ -57,14 +58,10 @@ pub(crate) trait Registry: DynClone {

clone_trait_object!(Registry);

pub(crate) trait RegistryGetQueryOpt<B, C>
where
B: Builder<B, C>,
C: QueryNodeConfig<B, C>,
{
fn get_query_node_factory(&self, id: String) -> Box<dyn QueryNodeFactory<B, C>>;
pub(crate) trait RegistryGetQueryOpt {
fn get_query_node_factory(&self, id: String) -> Box<dyn QueryNodeFactory>;

fn get_query_iter_factory(&self, id: String) -> Box<dyn QueryIteratorFactory<B, C>>;
fn get_query_iter_factory(&self, id: String) -> Box<dyn QueryIteratorFactory>;

fn get_query_iter_interpolator_factory(&self, id: String) -> Box<dyn QueryInterpolatorFactory>;
}
18 changes: 11 additions & 7 deletions src/common/core/tsdb.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use dyn_clone::{clone_trait_object, DynClone};
use hashed_wheel_timer::WheelTimer;

use crate::common::configuration::Configuration;
use crate::common::core::registry::Registry;
use crate::common::pool::executor::ExecutorService;
use crate::common::query::query_context::QueryContext;
use crate::common::query::query_node_config::{Builder, QueryNodeConfig};
use crate::common::stats::stats_collector::StatsCollector;
use crate::common::threadpools::tsdb_thread_pool_executor::TSDBThreadPoolExecutor;
use crate::common::{
configuration::configuration::Configuration,
core::registry::Registry,
pool::executor::ExecutorService,
query::{
query_context::QueryContext,
query_node_config::{Builder, QueryNodeConfig},

Check warning on line 10 in src/common/core/tsdb.rs

View workflow job for this annotation

GitHub Actions / Run tests (ubuntu-latest)

unused imports: `Builder`, `QueryNodeConfig`

Check warning on line 10 in src/common/core/tsdb.rs

View workflow job for this annotation

GitHub Actions / Run tests (macos-latest)

unused imports: `Builder`, `QueryNodeConfig`
},
stats::stats_collector::StatsCollector,
threadpools::tsdb_thread_pool_executor::TSDBThreadPoolExecutor,
};
#[async_trait::async_trait]
#[allow(clippy::upper_case_acronyms)]
pub(crate) trait TSDB: DynClone + Send + Sync {
Expand Down
4 changes: 2 additions & 2 deletions src/common/core/tsdb_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::common::core::tsdb::TSDB;

#[async_trait::async_trait]
pub(crate) trait TSDBPlugin: Send + Sync {
fn typ(&self) -> String;
pub(crate) trait TSDBPlugin {
fn get_type(&self) -> String;

fn id(&self) -> String;

Expand Down
Loading

0 comments on commit f789f77

Please sign in to comment.