Formatting changes after extract
This commit is contained in:
@@ -154,7 +154,10 @@ impl FromUrl for AccountingToplistQuery {
|
||||
.ok_or_else(|| Self::Error::MissingBackend)?
|
||||
.to_string(),
|
||||
ts: fn1(pairs)?,
|
||||
limit: pairs.get("limit").map_or(None, |x| x.parse().ok()).unwrap_or(20),
|
||||
limit: pairs
|
||||
.get("limit")
|
||||
.map_or(None, |x| x.parse().ok())
|
||||
.unwrap_or(20),
|
||||
sort: pairs.get("sort").map(ToString::to_string),
|
||||
};
|
||||
Ok(ret)
|
||||
|
||||
@@ -49,7 +49,10 @@ mod serde_option_vec_duration {
|
||||
match val {
|
||||
Some(vec) => {
|
||||
// humantime_serde::serialize(&t, ser)
|
||||
let t: Vec<_> = vec.iter().map(|&x| HumantimeDuration { inner: x }).collect();
|
||||
let t: Vec<_> = vec
|
||||
.iter()
|
||||
.map(|&x| HumantimeDuration { inner: x })
|
||||
.collect();
|
||||
serde::Serialize::serialize(&t, ser)
|
||||
}
|
||||
None => ser.serialize_none(),
|
||||
@@ -71,7 +74,11 @@ pub struct BinnedQuery {
|
||||
range: SeriesRange,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
bin_count: Option<u32>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none", with = "humantime_serde")]
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "humantime_serde"
|
||||
)]
|
||||
bin_width: Option<Duration>,
|
||||
#[serde(
|
||||
default = "TransformQuery::default_time_binned",
|
||||
@@ -80,7 +87,11 @@ pub struct BinnedQuery {
|
||||
transform: TransformQuery,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
cache_usage: Option<CacheUsage>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none", with = "serde_option_vec_duration")]
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "serde_option_vec_duration"
|
||||
)]
|
||||
subgrids: Option<Vec<Duration>>,
|
||||
#[serde(
|
||||
default,
|
||||
@@ -276,7 +287,9 @@ impl FromUrl for BinnedQuery {
|
||||
channel: SfDbChannel::from_pairs(&pairs)?,
|
||||
range: SeriesRange::from_pairs(pairs)?,
|
||||
bin_count: pairs.get("binCount").and_then(|x| x.parse().ok()),
|
||||
bin_width: pairs.get("binWidth").and_then(|x| humantime::parse_duration(x).ok()),
|
||||
bin_width: pairs
|
||||
.get("binWidth")
|
||||
.and_then(|x| humantime::parse_duration(x).ok()),
|
||||
transform: TransformQuery::from_pairs(pairs)?,
|
||||
cache_usage: CacheUsage::from_pairs(&pairs)?,
|
||||
buf_len_disk_io: pairs
|
||||
@@ -295,9 +308,11 @@ impl FromUrl for BinnedQuery {
|
||||
timeout_content: pairs
|
||||
.get("contentTimeout")
|
||||
.and_then(|x| humantime::parse_duration(x).ok()),
|
||||
subgrids: pairs
|
||||
.get("subgrids")
|
||||
.map(|x| x.split(",").filter_map(|x| humantime::parse_duration(x).ok()).collect()),
|
||||
subgrids: pairs.get("subgrids").map(|x| {
|
||||
x.split(",")
|
||||
.filter_map(|x| humantime::parse_duration(x).ok())
|
||||
.collect()
|
||||
}),
|
||||
merger_out_len_max: pairs
|
||||
.get("mergerOutLenMax")
|
||||
.map_or(Ok(None), |k| k.parse().map(|k| Some(k)))?,
|
||||
@@ -306,9 +321,9 @@ impl FromUrl for BinnedQuery {
|
||||
.map_or(Ok(None), |k| k.parse().map(|k| Some(k)))?,
|
||||
test_do_wasm: pairs.get("testDoWasm").map(|x| String::from(x)),
|
||||
log_level: pairs.get("log_level").map_or(String::new(), String::from),
|
||||
use_rt: pairs
|
||||
.get("useRt")
|
||||
.map_or(Ok(None), |k| k.parse().map(Some).map_err(|_| Error::BadUseRt))?,
|
||||
use_rt: pairs.get("useRt").map_or(Ok(None), |k| {
|
||||
k.parse().map(Some).map_err(|_| Error::BadUseRt)
|
||||
})?,
|
||||
};
|
||||
debug!("BinnedQuery::from_url {:?}", ret);
|
||||
Ok(ret)
|
||||
@@ -347,16 +362,16 @@ impl AppendToUrl for BinnedQuery {
|
||||
g.append_pair("contentTimeout", &format!("{:.0}ms", 1e3 * x.as_secs_f64()));
|
||||
}
|
||||
if let Some(x) = &self.subgrids {
|
||||
let s: String =
|
||||
x.iter()
|
||||
.map(|&x| humantime::format_duration(x).to_string())
|
||||
.fold(String::new(), |mut a, x| {
|
||||
if a.len() != 0 {
|
||||
a.push_str(",");
|
||||
}
|
||||
a.push_str(&x);
|
||||
a
|
||||
});
|
||||
let s: String = x
|
||||
.iter()
|
||||
.map(|&x| humantime::format_duration(x).to_string())
|
||||
.fold(String::new(), |mut a, x| {
|
||||
if a.len() != 0 {
|
||||
a.push_str(",");
|
||||
}
|
||||
a.push_str(&x);
|
||||
a
|
||||
});
|
||||
g.append_pair("subgrids", &s);
|
||||
}
|
||||
if let Some(x) = self.buf_len_disk_io {
|
||||
|
||||
@@ -55,7 +55,11 @@ pub struct PlainEventsQuery {
|
||||
bytes_max: Option<u64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
allow_large_result: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none", with = "humantime_serde")]
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "humantime_serde"
|
||||
)]
|
||||
event_delay: Option<Duration>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
stream_batch_len: Option<usize>,
|
||||
@@ -134,6 +138,10 @@ impl PlainEventsQuery {
|
||||
self.timeout_content
|
||||
}
|
||||
|
||||
pub fn timeout_content_or_default(&self) -> Duration {
|
||||
self.timeout_content.unwrap_or(Duration::from_millis(3000))
|
||||
}
|
||||
|
||||
pub fn events_max(&self) -> u64 {
|
||||
self.events_max.map_or_else(
|
||||
|| {
|
||||
@@ -281,9 +289,13 @@ impl FromUrl for PlainEventsQuery {
|
||||
.and_then(|x| humantime::parse_duration(x).ok()),
|
||||
events_max: pairs.get("eventsMax").map_or(None, |k| k.parse().ok()),
|
||||
bytes_max: pairs.get("bytesMax").map_or(None, |k| k.parse().ok()),
|
||||
allow_large_result: pairs.get("allowLargeResult").map_or(None, |x| x.parse().ok()),
|
||||
allow_large_result: pairs
|
||||
.get("allowLargeResult")
|
||||
.map_or(None, |x| x.parse().ok()),
|
||||
event_delay: pairs.get("eventDelay").map_or(Ok(None), |k| {
|
||||
k.parse::<u64>().map(|x| Duration::from_millis(x)).map(|k| Some(k))
|
||||
k.parse::<u64>()
|
||||
.map(|x| Duration::from_millis(x))
|
||||
.map(|k| Some(k))
|
||||
})?,
|
||||
stream_batch_len: pairs
|
||||
.get("streamBatchLen")
|
||||
@@ -318,10 +330,12 @@ impl FromUrl for PlainEventsQuery {
|
||||
.map(|x| x.split(",").map(|x| x.to_string()).collect())
|
||||
.unwrap_or(Vec::new()),
|
||||
log_level: pairs.get("log_level").map_or(String::new(), String::from),
|
||||
use_rt: pairs
|
||||
.get("useRt")
|
||||
.map_or(Ok(None), |k| k.parse().map(Some).map_err(|_| Error::BadQuery))?,
|
||||
querymarker: pairs.get("querymarker").map_or(String::new(), |x| x.to_string()),
|
||||
use_rt: pairs.get("useRt").map_or(Ok(None), |k| {
|
||||
k.parse().map(Some).map_err(|_| Error::BadQuery)
|
||||
})?,
|
||||
querymarker: pairs
|
||||
.get("querymarker")
|
||||
.map_or(String::new(), |x| x.to_string()),
|
||||
};
|
||||
Ok(ret)
|
||||
}
|
||||
@@ -580,7 +594,9 @@ impl EventsSubQuery {
|
||||
}
|
||||
|
||||
pub fn timeout(&self) -> Duration {
|
||||
self.settings.timeout.unwrap_or(Duration::from_millis(10000))
|
||||
self.settings
|
||||
.timeout
|
||||
.unwrap_or(Duration::from_millis(10000))
|
||||
}
|
||||
|
||||
pub fn events_max(&self) -> u64 {
|
||||
|
||||
Reference in New Issue
Block a user