Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"asap-common/dependencies/rs/sketch_db_common",
"asap-common/dependencies/rs/datafusion_summary_library",
"asap-query-engine",
"asap-planner-rs",
]

[workspace.package]
Expand All @@ -33,3 +34,5 @@ promql_utilities = { path = "asap-common/dependencies/rs/promql_utilities" }
sql_utilities = { path = "asap-common/dependencies/rs/sql_utilities" }
sketch_db_common = { path = "asap-common/dependencies/rs/sketch_db_common" }
datafusion_summary_library = { path = "asap-common/dependencies/rs/datafusion_summary_library" }
asap_planner = { path = "asap-planner-rs" }
indexmap = { version = "2.0", features = ["serde"] }
30 changes: 30 additions & 0 deletions asap-planner-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "asap_planner"
version.workspace = true
edition.workspace = true

[lib]
name = "asap_planner"
path = "src/lib.rs"

[[bin]]
name = "asap-planner"
path = "src/main.rs"

[dependencies]
sketch_db_common.workspace = true
promql_utilities.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
thiserror.workspace = true
anyhow.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
clap.workspace = true
indexmap.workspace = true
promql-parser = "0.5.0"

[dev-dependencies]
tempfile = "3.20"
pretty_assertions = "1.4"
72 changes: 72 additions & 0 deletions asap-planner-rs/src/config/input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use serde::Deserialize;

#[derive(Debug, Clone, Deserialize)]
pub struct ControllerConfig {
pub query_groups: Vec<QueryGroup>,
pub metrics: Vec<MetricDefinition>,
pub sketch_parameters: Option<SketchParameterOverrides>,
pub aggregate_cleanup: Option<AggregateCleanupConfig>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct QueryGroup {
pub id: Option<u32>,
pub queries: Vec<String>,
pub repetition_delay: u64,
pub controller_options: ControllerOptions,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ControllerOptions {
pub accuracy_sla: f64,
pub latency_sla: f64,
}

#[derive(Debug, Clone, Deserialize)]
pub struct MetricDefinition {
pub metric: String,
pub labels: Vec<String>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct AggregateCleanupConfig {
pub policy: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Default)]
pub struct SketchParameterOverrides {
#[serde(rename = "CountMinSketch")]
pub count_min_sketch: Option<CmsParams>,
#[serde(rename = "CountMinSketchWithHeap")]
pub count_min_sketch_with_heap: Option<CmsHeapParams>,
#[serde(rename = "DatasketchesKLL")]
pub datasketches_kll: Option<KllParams>,
#[serde(rename = "HydraKLL")]
pub hydra_kll: Option<HydraParams>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct CmsParams {
pub depth: u64,
pub width: u64,
}

#[derive(Debug, Clone, Deserialize)]
pub struct CmsHeapParams {
pub depth: u64,
pub width: u64,
pub heap_multiplier: Option<u64>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct KllParams {
#[serde(rename = "K")]
pub k: u64,
}

#[derive(Debug, Clone, Deserialize)]
pub struct HydraParams {
pub row_num: u64,
pub col_num: u64,
pub k: u64,
}
2 changes: 2 additions & 0 deletions asap-planner-rs/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod input;
pub use input::*;
17 changes: 17 additions & 0 deletions asap-planner-rs/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ControllerError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("YAML parse error: {0}")]
YamlParse(#[from] serde_yaml::Error),
#[error("PromQL parse error: {0}")]
PromQLParse(String),
#[error("Duplicate query: {0}")]
DuplicateQuery(String),
#[error("Planner error: {0}")]
PlannerError(String),
#[error("Unknown metric: {0}")]
UnknownMetric(String),
}
Loading
Loading