Rename SfDbChannel

This commit is contained in:
Dominik Werder
2023-06-13 16:17:08 +02:00
parent 9c0062d27c
commit 7c77b07db5
40 changed files with 733 additions and 1024 deletions
+12 -12
View File
@@ -595,12 +595,12 @@ pub struct NodeStatus {
pub subs: VecDeque<NodeStatusSub>,
}
// Describes a "channel" which is a time-series with a unique name within a "backend".
// Describes a swissfel-databuffer style "channel" which is a time-series with a unique name within a "backend".
// Also the concept of "backend" could be split into "facility" and some optional other identifier
// for cases like e.g. post-mortem, or to differentiate between channel-access and bsread for cases where
// the same channel-name is delivered via different methods.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Channel {
pub struct SfDbChannel {
pub series: Option<u64>,
// "backend" is currently used in the existing systems for multiple purposes:
// it can indicate the facility (eg. sf-databuffer, hipa, ...) but also
@@ -609,7 +609,7 @@ pub struct Channel {
pub name: String,
}
impl Channel {
impl SfDbChannel {
pub fn backend(&self) -> &str {
&self.backend
}
@@ -623,14 +623,14 @@ impl Channel {
}
}
impl FromUrl for Channel {
impl FromUrl for SfDbChannel {
fn from_url(url: &Url) -> Result<Self, Error> {
let pairs = get_url_query_pairs(url);
Self::from_pairs(&pairs)
}
fn from_pairs(pairs: &BTreeMap<String, String>) -> Result<Self, Error> {
let ret = Channel {
let ret = SfDbChannel {
backend: pairs
.get("backend")
.ok_or(Error::with_public_msg("missing backend"))?
@@ -654,7 +654,7 @@ impl FromUrl for Channel {
}
}
impl AppendToUrl for Channel {
impl AppendToUrl for SfDbChannel {
fn append_to_url(&self, url: &mut Url) {
let mut g = url.query_pairs_mut();
g.append_pair("backend", &self.backend);
@@ -669,13 +669,13 @@ impl AppendToUrl for Channel {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ChannelTyped {
pub channel: Channel,
pub channel: SfDbChannel,
pub scalar_type: ScalarType,
pub shape: Shape,
}
impl ChannelTyped {
pub fn channel(&self) -> &Channel {
pub fn channel(&self) -> &SfDbChannel {
&self.channel
}
}
@@ -2238,7 +2238,7 @@ pub fn get_url_query_pairs(url: &Url) -> BTreeMap<String, String> {
// The presence of a configuration in some range does not imply that there is any data available.
#[derive(Debug, Serialize, Deserialize)]
pub struct ChannelConfigQuery {
pub channel: Channel,
pub channel: SfDbChannel,
pub range: NanoRange,
pub expand: bool,
}
@@ -2265,14 +2265,14 @@ impl FromUrl for ChannelConfigQuery {
let beg_date = pairs
.get("begDate")
.map(String::from)
.unwrap_or_else(|| String::from("2000-01-01T00:00:00Z"));
.unwrap_or_else(|| String::from("1970-01-01T00:00:00Z"));
let end_date = pairs
.get("endDate")
.map(String::from)
.unwrap_or_else(|| String::from("3000-01-01T00:00:00Z"));
let expand = pairs.get("expand").map(|s| s == "true").unwrap_or(false);
let ret = Self {
channel: Channel::from_pairs(&pairs)?,
channel: SfDbChannel::from_pairs(&pairs)?,
range: NanoRange {
beg: beg_date.parse::<DateTime<Utc>>()?.to_nanos(),
end: end_date.parse::<DateTime<Utc>>()?.to_nanos(),
@@ -2305,7 +2305,7 @@ impl AppendToUrl for ChannelConfigQuery {
#[derive(Debug, Serialize, Deserialize)]
pub struct ChannelConfigResponse {
#[serde(rename = "channel")]
pub channel: Channel,
pub channel: SfDbChannel,
#[serde(rename = "scalarType")]
pub scalar_type: ScalarType,
#[serde(rename = "byteOrder", default, skip_serializing_if = "Option::is_none")]
+6 -6
View File
@@ -8,13 +8,13 @@ use crate::log::*;
use crate::AggKind;
use crate::AppendToUrl;
use crate::ByteSize;
use crate::Channel;
use crate::FromUrl;
use crate::HasBackend;
use crate::HasTimeout;
use crate::NanoRange;
use crate::PulseRange;
use crate::SeriesRange;
use crate::SfDbChannel;
use crate::ToNanos;
use chrono::DateTime;
use chrono::TimeZone;
@@ -252,12 +252,12 @@ pub fn agg_kind_from_binning_scheme(pairs: &BTreeMap<String, String>) -> Result<
#[derive(Clone, Debug)]
pub struct ChannelStateEventsQuery {
channel: Channel,
channel: SfDbChannel,
range: NanoRange,
}
impl ChannelStateEventsQuery {
pub fn new(channel: Channel, range: NanoRange) -> Self {
pub fn new(channel: SfDbChannel, range: NanoRange) -> Self {
Self { channel, range }
}
@@ -265,7 +265,7 @@ impl ChannelStateEventsQuery {
&self.range
}
pub fn channel(&self) -> &Channel {
pub fn channel(&self) -> &SfDbChannel {
&self.channel
}
@@ -273,7 +273,7 @@ impl ChannelStateEventsQuery {
self.channel.series = Some(series);
}
pub fn channel_mut(&mut self) -> &mut Channel {
pub fn channel_mut(&mut self) -> &mut SfDbChannel {
&mut self.channel
}
}
@@ -300,7 +300,7 @@ impl FromUrl for ChannelStateEventsQuery {
let beg_date = pairs.get("begDate").ok_or(Error::with_msg("missing begDate"))?;
let end_date = pairs.get("endDate").ok_or(Error::with_msg("missing endDate"))?;
let ret = Self {
channel: Channel::from_pairs(&pairs)?,
channel: SfDbChannel::from_pairs(&pairs)?,
range: NanoRange {
beg: beg_date.parse::<DateTime<Utc>>()?.to_nanos(),
end: end_date.parse::<DateTime<Utc>>()?.to_nanos(),
+5 -5
View File
@@ -4,10 +4,10 @@ use super::CacheUsage;
use crate::AggKind;
use crate::AppendToUrl;
use crate::ByteSize;
use crate::Channel;
use crate::FromUrl;
use crate::PreBinnedPatchCoordEnum;
use crate::ScalarType;
use crate::SfDbChannel;
use crate::Shape;
use err::Error;
use std::collections::BTreeMap;
@@ -16,7 +16,7 @@ use url::Url;
#[derive(Clone, Debug)]
pub struct PreBinnedQuery {
patch: PreBinnedPatchCoordEnum,
channel: Channel,
channel: SfDbChannel,
scalar_type: ScalarType,
shape: Shape,
agg_kind: Option<AggKind>,
@@ -28,7 +28,7 @@ pub struct PreBinnedQuery {
impl PreBinnedQuery {
pub fn new(
patch: PreBinnedPatchCoordEnum,
channel: Channel,
channel: SfDbChannel,
scalar_type: ScalarType,
shape: Shape,
agg_kind: Option<AggKind>,
@@ -64,7 +64,7 @@ impl PreBinnedQuery {
.map(|x| Shape::from_url_str(&x))??;
let ret = Self {
patch: PreBinnedPatchCoordEnum::from_pairs(&pairs)?,
channel: Channel::from_pairs(&pairs)?,
channel: SfDbChannel::from_pairs(&pairs)?,
scalar_type,
shape,
agg_kind: agg_kind_from_binning_scheme(&pairs)?,
@@ -85,7 +85,7 @@ impl PreBinnedQuery {
&self.patch
}
pub fn channel(&self) -> &Channel {
pub fn channel(&self) -> &SfDbChannel {
&self.channel
}