From b573b87e1da39089c72acf8b034e091e30549cf9 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Wed, 13 Oct 2021 22:59:24 +0300 Subject: [PATCH] metric begin --- Cargo.lock | 110 +++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 3 +- src/lib.rs | 1 + src/main.rs | 15 ++++++- src/metric.rs | 29 +++++++++++++ 5 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/lib.rs create mode 100644 src/metric.rs diff --git a/Cargo.lock b/Cargo.lock index 64e955b..db4e761 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,114 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "subbeat" -version = "0.0.1" +version = "0.0.2" +dependencies = [ + "clap", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 34d0524..ed61ccc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subbeat" -version = "0.0.1" +version = "0.0.2" edition = "2018" license = "MIT OR Apache-2.0" @@ -13,3 +13,4 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = "2.33.3" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..3be827e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod metric; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index bc9c703..06437ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,16 @@ +use clap::{Arg, App, SubCommand}; + fn main() { - println!("welcom from subbeat, work in progress"); + let matches = App::new("My Super Program") + .version("0.0.2") + .about("Timeseries toolkit") + .arg(Arg::with_name("INPUT") + .help("Sets the input file to use") + .required(true) + .index(1)) + .get_matches(); + + let input = matches.value_of("INPUT").unwrap(); + + println!("input file for influxdb {}", input); } diff --git a/src/metric.rs b/src/metric.rs new file mode 100644 index 0000000..56978af --- /dev/null +++ b/src/metric.rs @@ -0,0 +1,29 @@ +use std::collections::HashMap; + + +pub type MetricId = String; + +struct DatasourceParams { + db: String, + q: String, + epoch: String +} + +struct Datasource { + url: String, + dtype: String, + params: Option, + data: Option>, + datasource_id: Option +} + +struct MetricQuery { + url: String, + method: String, + schema: HashMap, + headers: Option> + } + +trait Metric { + fn query(); +} \ No newline at end of file