Add query option
This commit is contained in:
@@ -12,8 +12,5 @@ chrono = { version = "0.4.38", features = ["serde"] }
|
||||
url = "2.5.3"
|
||||
humantime = "2.1.0"
|
||||
humantime-serde = "1.1.1"
|
||||
thiserror = "=0.0.1"
|
||||
autoerr = "0.0.3"
|
||||
netpod = { path = "../daqbuf-netpod", package = "daqbuf-netpod" }
|
||||
|
||||
[patch.crates-io]
|
||||
thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" }
|
||||
|
||||
19
src/api4.rs
19
src/api4.rs
@@ -20,15 +20,16 @@ use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "Query")]
|
||||
pub enum Error {
|
||||
MissingTimerange,
|
||||
ChronoParse(#[from] chrono::ParseError),
|
||||
HumantimeDurationParse(#[from] humantime::DurationError),
|
||||
MissingBackend,
|
||||
MissingRetentionTime,
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "Query"),
|
||||
enum variants {
|
||||
MissingTimerange,
|
||||
ChronoParse(#[from] chrono::ParseError),
|
||||
HumantimeDurationParse(#[from] humantime::DurationError),
|
||||
MissingBackend,
|
||||
MissingRetentionTime,
|
||||
},
|
||||
);
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AccountingIngestedBytesQuery {
|
||||
|
||||
@@ -19,15 +19,16 @@ use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "BinnedQuery")]
|
||||
pub enum Error {
|
||||
BadInt(#[from] std::num::ParseIntError),
|
||||
MultipleBinCountBinWidth,
|
||||
BadUseRt,
|
||||
Netpod(#[from] netpod::Error),
|
||||
Transform(#[from] crate::transform::Error),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "BinnedQuery"),
|
||||
enum variants {
|
||||
BadInt(#[from] std::num::ParseIntError),
|
||||
MultipleBinCountBinWidth,
|
||||
BadUseRt,
|
||||
Netpod(#[from] netpod::Error),
|
||||
Transform(#[from] crate::transform::Error),
|
||||
},
|
||||
);
|
||||
|
||||
mod serde_option_vec_duration {
|
||||
use serde::Deserialize;
|
||||
@@ -105,15 +106,21 @@ pub struct BinnedQuery {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
disk_stats_every: Option<ByteSize>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub merger_out_len_max: Option<u32>,
|
||||
merger_out_len_max: Option<u32>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
scylla_read_queue_len: Option<u32>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
test_do_wasm: Option<String>,
|
||||
#[serde(default)]
|
||||
log_level: String,
|
||||
#[serde(default)]
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
use_rt: Option<RetentionTime>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
allow_from_events: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
allow_from_prebinned: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
allow_rebin: Option<bool>,
|
||||
}
|
||||
|
||||
impl BinnedQuery {
|
||||
@@ -134,6 +141,9 @@ impl BinnedQuery {
|
||||
test_do_wasm: None,
|
||||
log_level: String::new(),
|
||||
use_rt: None,
|
||||
allow_from_events: None,
|
||||
allow_from_prebinned: None,
|
||||
allow_rebin: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,6 +334,15 @@ impl FromUrl for BinnedQuery {
|
||||
use_rt: pairs.get("useRt").map_or(Ok(None), |k| {
|
||||
k.parse().map(Some).map_err(|_| Error::BadUseRt)
|
||||
})?,
|
||||
allow_from_events: pairs
|
||||
.get("allow_from_events")
|
||||
.and_then(|x| x.parse::<bool>().ok()),
|
||||
allow_from_prebinned: pairs
|
||||
.get("allow_from_prebinned")
|
||||
.and_then(|x| x.parse::<bool>().ok()),
|
||||
allow_rebin: pairs
|
||||
.get("allow_rebin")
|
||||
.and_then(|x| x.parse::<bool>().ok()),
|
||||
};
|
||||
debug!("BinnedQuery::from_url {:?}", ret);
|
||||
Ok(ret)
|
||||
@@ -395,5 +414,14 @@ impl AppendToUrl for BinnedQuery {
|
||||
if let Some(x) = self.use_rt.as_ref() {
|
||||
g.append_pair("useRt", &x.to_string());
|
||||
}
|
||||
if let Some(x) = self.allow_from_events.as_ref() {
|
||||
g.append_pair("allow_from_events", &x.to_string());
|
||||
}
|
||||
if let Some(x) = self.allow_from_prebinned.as_ref() {
|
||||
g.append_pair("allow_from_prebinned", &x.to_string());
|
||||
}
|
||||
if let Some(x) = self.allow_rebin.as_ref() {
|
||||
g.append_pair("allow_rebin", &x.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,16 @@ use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "EventsQuery")]
|
||||
pub enum Error {
|
||||
BadInt(#[from] std::num::ParseIntError),
|
||||
MissingTimerange,
|
||||
BadQuery,
|
||||
Transform(#[from] crate::transform::Error),
|
||||
Netpod(#[from] netpod::Error),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "EventsQuery"),
|
||||
enum variants {
|
||||
BadInt(#[from] std::num::ParseIntError),
|
||||
MissingTimerange,
|
||||
BadQuery,
|
||||
Transform(#[from] crate::transform::Error),
|
||||
Netpod(#[from] netpod::Error),
|
||||
},
|
||||
);
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct PlainEventsQuery {
|
||||
@@ -122,6 +123,10 @@ impl PlainEventsQuery {
|
||||
&self.range
|
||||
}
|
||||
|
||||
pub fn beg_excl(&self) -> bool {
|
||||
self.beg_excl
|
||||
}
|
||||
|
||||
pub fn one_before_range(&self) -> bool {
|
||||
self.one_before_range || self.transform.need_one_before_range()
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@ use netpod::FromUrl;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
use thiserror;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "Query")]
|
||||
pub enum Error {
|
||||
ParseInt(#[from] std::num::ParseIntError),
|
||||
BadEnumAsString,
|
||||
BadBinningScheme,
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "Transform"),
|
||||
enum variants {
|
||||
ParseInt(#[from] std::num::ParseIntError),
|
||||
BadEnumAsString,
|
||||
BadBinningScheme,
|
||||
},
|
||||
);
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub enum EventTransformQuery {
|
||||
|
||||
Reference in New Issue
Block a user