Support search for status channel and data fetch
This commit is contained in:
@@ -109,7 +109,7 @@ pub(super) async fn search_channel_scylla(
|
|||||||
let ret = ChannelSearchResult { channels: Vec::new() };
|
let ret = ChannelSearchResult { channels: Vec::new() };
|
||||||
return Ok(ret);
|
return Ok(ret);
|
||||||
}
|
}
|
||||||
let ch_kind: i16 = if query.channel_status { 1 } else { 2 };
|
let ch_kind: i16 = query.kind.to_db_i16();
|
||||||
let (cb1, cb2) = if let Some(x) = query.backend.as_ref() {
|
let (cb1, cb2) = if let Some(x) = query.backend.as_ref() {
|
||||||
(false, x.as_str())
|
(false, x.as_str())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -270,7 +270,6 @@ fn make_scalar_conv(
|
|||||||
ScalarType::BOOL => ValueDim0FromBytesImpl::<bool>::boxed(),
|
ScalarType::BOOL => ValueDim0FromBytesImpl::<bool>::boxed(),
|
||||||
ScalarType::STRING => ValueDim0FromBytesImpl::<String>::boxed(),
|
ScalarType::STRING => ValueDim0FromBytesImpl::<String>::boxed(),
|
||||||
ScalarType::Enum => ValueDim0FromBytesImpl::<String>::boxed(),
|
ScalarType::Enum => ValueDim0FromBytesImpl::<String>::boxed(),
|
||||||
ScalarType::ChannelStatus => ValueDim0FromBytesImpl::<u32>::boxed(),
|
|
||||||
},
|
},
|
||||||
Shape::Wave(_) => {
|
Shape::Wave(_) => {
|
||||||
let shape = shape.clone();
|
let shape = shape.clone();
|
||||||
@@ -288,7 +287,6 @@ fn make_scalar_conv(
|
|||||||
ScalarType::BOOL => ValueDim1FromBytesImpl::<bool>::boxed(shape),
|
ScalarType::BOOL => ValueDim1FromBytesImpl::<bool>::boxed(shape),
|
||||||
ScalarType::STRING => ValueDim1FromBytesImpl::<String>::boxed(shape),
|
ScalarType::STRING => ValueDim1FromBytesImpl::<String>::boxed(shape),
|
||||||
ScalarType::Enum => ValueDim1FromBytesImpl::<String>::boxed(shape),
|
ScalarType::Enum => ValueDim1FromBytesImpl::<String>::boxed(shape),
|
||||||
ScalarType::ChannelStatus => ValueDim1FromBytesImpl::<u32>::boxed(shape),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Shape::Image(_, _) => {
|
Shape::Image(_, _) => {
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ impl FileContentStream2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_mut)]
|
||||||
fn make_reading(&mut self) {
|
fn make_reading(&mut self) {
|
||||||
let mut buf = Box::new(BytesMut::with_capacity(self.disk_io_tune.read_buffer_len));
|
let mut buf = Box::new(BytesMut::with_capacity(self.disk_io_tune.read_buffer_len));
|
||||||
// let bufref = unsafe { &mut *((&mut buf as &mut BytesMut) as *mut BytesMut) };
|
// let bufref = unsafe { &mut *((&mut buf as &mut BytesMut) as *mut BytesMut) };
|
||||||
@@ -783,7 +784,8 @@ impl BlockingTaskIntoChannel {
|
|||||||
let item = FileChunkRead::with_buf_dur(buf, ts2.duration_since(ts1));
|
let item = FileChunkRead::with_buf_dur(buf, ts2.duration_since(ts1));
|
||||||
match tx.send_blocking(Ok(item)) {
|
match tx.send_blocking(Ok(item)) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(e) => {
|
Err(_) => {
|
||||||
|
// TODO
|
||||||
// Receiver most likely disconnected.
|
// Receiver most likely disconnected.
|
||||||
// error!("blocking_task_into_channel can not send into channel {e}");
|
// error!("blocking_task_into_channel can not send into channel {e}");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ use netpod::FromUrl;
|
|||||||
use netpod::NodeConfigCached;
|
use netpod::NodeConfigCached;
|
||||||
use netpod::ProxyConfig;
|
use netpod::ProxyConfig;
|
||||||
use netpod::ReqCtxArc;
|
use netpod::ReqCtxArc;
|
||||||
|
use netpod::SeriesKind;
|
||||||
use netpod::SfChFetchInfo;
|
use netpod::SfChFetchInfo;
|
||||||
use netpod::SfDbChannel;
|
use netpod::SfDbChannel;
|
||||||
use netpod::Shape;
|
use netpod::Shape;
|
||||||
@@ -160,8 +161,8 @@ pub async fn channel_search_list_v1(
|
|||||||
name_regex: query.regex.map_or(String::new(), |k| k),
|
name_regex: query.regex.map_or(String::new(), |k| k),
|
||||||
source_regex: query.source_regex.map_or(String::new(), |k| k),
|
source_regex: query.source_regex.map_or(String::new(), |k| k),
|
||||||
description_regex: query.description_regex.map_or(String::new(), |k| k),
|
description_regex: query.description_regex.map_or(String::new(), |k| k),
|
||||||
channel_status: false,
|
|
||||||
icase: false,
|
icase: false,
|
||||||
|
kind: SeriesKind::default(),
|
||||||
};
|
};
|
||||||
let urls = proxy_config
|
let urls = proxy_config
|
||||||
.backends
|
.backends
|
||||||
@@ -271,8 +272,8 @@ pub async fn channel_search_configs_v1(
|
|||||||
name_regex: query.regex.map_or(String::new(), |k| k),
|
name_regex: query.regex.map_or(String::new(), |k| k),
|
||||||
source_regex: query.source_regex.map_or(String::new(), |k| k),
|
source_regex: query.source_regex.map_or(String::new(), |k| k),
|
||||||
description_regex: query.description_regex.map_or(String::new(), |k| k),
|
description_regex: query.description_regex.map_or(String::new(), |k| k),
|
||||||
channel_status: false,
|
|
||||||
icase: false,
|
icase: false,
|
||||||
|
kind: SeriesKind::default(),
|
||||||
};
|
};
|
||||||
let urls = proxy_config
|
let urls = proxy_config
|
||||||
.backends
|
.backends
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ pub fn empty_events_dyn_ev(scalar_type: &ScalarType, shape: &Shape) -> Result<Bo
|
|||||||
BOOL => Box::new(K::<bool>::empty()),
|
BOOL => Box::new(K::<bool>::empty()),
|
||||||
STRING => Box::new(K::<String>::empty()),
|
STRING => Box::new(K::<String>::empty()),
|
||||||
Enum => Box::new(K::<EnumVariant>::empty()),
|
Enum => Box::new(K::<EnumVariant>::empty()),
|
||||||
ChannelStatus => Box::new(K::<u32>::empty()),
|
|
||||||
CaStatus => Box::new(K::<i16>::empty()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Shape::Wave(..) => {
|
Shape::Wave(..) => {
|
||||||
@@ -48,8 +46,6 @@ pub fn empty_events_dyn_ev(scalar_type: &ScalarType, shape: &Shape) -> Result<Bo
|
|||||||
BOOL => Box::new(K::<bool>::empty()),
|
BOOL => Box::new(K::<bool>::empty()),
|
||||||
STRING => Box::new(K::<String>::empty()),
|
STRING => Box::new(K::<String>::empty()),
|
||||||
Enum => Box::new(K::<EnumVariant>::empty()),
|
Enum => Box::new(K::<EnumVariant>::empty()),
|
||||||
ChannelStatus => Box::new(K::<u32>::empty()),
|
|
||||||
CaStatus => Box::new(K::<i16>::empty()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Shape::Image(..) => {
|
Shape::Image(..) => {
|
||||||
|
|||||||
@@ -187,8 +187,8 @@ impl SeriesKind {
|
|||||||
|
|
||||||
pub fn from_db_i16(x: i16) -> Result<Self, Error> {
|
pub fn from_db_i16(x: i16) -> Result<Self, Error> {
|
||||||
let ret = match x {
|
let ret = match x {
|
||||||
1 => Self::ChannelData,
|
1 => Self::ChannelStatus,
|
||||||
2 => Self::ChannelStatus,
|
2 => Self::ChannelData,
|
||||||
3 => Self::CaStatus,
|
3 => Self::CaStatus,
|
||||||
_ => return Err(Error::with_msg_no_trace("bad SeriesKind value")),
|
_ => return Err(Error::with_msg_no_trace("bad SeriesKind value")),
|
||||||
};
|
};
|
||||||
@@ -249,7 +249,6 @@ pub enum ScalarType {
|
|||||||
BOOL,
|
BOOL,
|
||||||
STRING,
|
STRING,
|
||||||
Enum,
|
Enum,
|
||||||
ChannelStatus,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for ScalarType {
|
impl fmt::Debug for ScalarType {
|
||||||
@@ -284,7 +283,6 @@ impl Serialize for ScalarType {
|
|||||||
BOOL => ser.serialize_str("bool"),
|
BOOL => ser.serialize_str("bool"),
|
||||||
STRING => ser.serialize_str("string"),
|
STRING => ser.serialize_str("string"),
|
||||||
Enum => ser.serialize_str("enum"),
|
Enum => ser.serialize_str("enum"),
|
||||||
ChannelStatus => ser.serialize_str("channelstatus"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +313,6 @@ impl<'de> serde::de::Visitor<'de> for ScalarTypeVis {
|
|||||||
"bool" => BOOL,
|
"bool" => BOOL,
|
||||||
"string" => STRING,
|
"string" => STRING,
|
||||||
"enum" => Enum,
|
"enum" => Enum,
|
||||||
"channelstatus" => ChannelStatus,
|
|
||||||
k => return Err(E::custom(format!("can not understand variant {k:?}"))),
|
k => return Err(E::custom(format!("can not understand variant {k:?}"))),
|
||||||
};
|
};
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
@@ -352,7 +349,6 @@ impl ScalarType {
|
|||||||
11 => F32,
|
11 => F32,
|
||||||
12 => F64,
|
12 => F64,
|
||||||
13 => STRING,
|
13 => STRING,
|
||||||
14 => ChannelStatus,
|
|
||||||
15 => Enum,
|
15 => Enum,
|
||||||
6 => return Err(Error::with_msg(format!("CHARACTER not supported"))),
|
6 => return Err(Error::with_msg(format!("CHARACTER not supported"))),
|
||||||
_ => return Err(Error::with_msg(format!("unknown dtype code: {:?}", ix))),
|
_ => return Err(Error::with_msg(format!("unknown dtype code: {:?}", ix))),
|
||||||
@@ -376,7 +372,6 @@ impl ScalarType {
|
|||||||
BOOL => "bool",
|
BOOL => "bool",
|
||||||
STRING => "string",
|
STRING => "string",
|
||||||
Enum => "enum",
|
Enum => "enum",
|
||||||
ChannelStatus => "channelstatus",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +391,6 @@ impl ScalarType {
|
|||||||
"bool" => BOOL,
|
"bool" => BOOL,
|
||||||
"string" => STRING,
|
"string" => STRING,
|
||||||
"enum" => Enum,
|
"enum" => Enum,
|
||||||
"channelstatus" => ChannelStatus,
|
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::with_msg_no_trace(format!(
|
return Err(Error::with_msg_no_trace(format!(
|
||||||
"from_bsread_str can not understand bsread {:?}",
|
"from_bsread_str can not understand bsread {:?}",
|
||||||
@@ -423,7 +417,6 @@ impl ScalarType {
|
|||||||
BOOL => "bool",
|
BOOL => "bool",
|
||||||
STRING => "string",
|
STRING => "string",
|
||||||
Enum => "enum",
|
Enum => "enum",
|
||||||
ChannelStatus => "channelstatus",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +438,6 @@ impl ScalarType {
|
|||||||
"bool" => BOOL,
|
"bool" => BOOL,
|
||||||
"string" => STRING,
|
"string" => STRING,
|
||||||
"enum" => Enum,
|
"enum" => Enum,
|
||||||
"channelstatus" => ChannelStatus,
|
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::with_msg_no_trace(format!(
|
return Err(Error::with_msg_no_trace(format!(
|
||||||
"from_bsread_str can not understand bsread {:?}",
|
"from_bsread_str can not understand bsread {:?}",
|
||||||
@@ -534,7 +526,6 @@ impl ScalarType {
|
|||||||
BOOL => 1,
|
BOOL => 1,
|
||||||
STRING => 1,
|
STRING => 1,
|
||||||
Enum => 2,
|
Enum => 2,
|
||||||
ChannelStatus => 4,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +544,6 @@ impl ScalarType {
|
|||||||
F64 => 12,
|
F64 => 12,
|
||||||
BOOL => 0,
|
BOOL => 0,
|
||||||
STRING => 13,
|
STRING => 13,
|
||||||
ChannelStatus => 14,
|
|
||||||
Enum => 15,
|
Enum => 15,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2999,9 +2989,9 @@ pub struct ChannelSearchQuery {
|
|||||||
pub source_regex: String,
|
pub source_regex: String,
|
||||||
pub description_regex: String,
|
pub description_regex: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub channel_status: bool,
|
|
||||||
#[serde(default)]
|
|
||||||
pub icase: bool,
|
pub icase: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub kind: SeriesKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelSearchQuery {
|
impl ChannelSearchQuery {
|
||||||
@@ -3012,12 +3002,8 @@ impl ChannelSearchQuery {
|
|||||||
name_regex: pairs.get("nameRegex").map_or(String::new(), |k| k.clone()),
|
name_regex: pairs.get("nameRegex").map_or(String::new(), |k| k.clone()),
|
||||||
source_regex: pairs.get("sourceRegex").map_or(String::new(), |k| k.clone()),
|
source_regex: pairs.get("sourceRegex").map_or(String::new(), |k| k.clone()),
|
||||||
description_regex: pairs.get("descriptionRegex").map_or(String::new(), |k| k.clone()),
|
description_regex: pairs.get("descriptionRegex").map_or(String::new(), |k| k.clone()),
|
||||||
channel_status: pairs
|
|
||||||
.get("channelStatus")
|
|
||||||
.map(|k| k.parse().ok())
|
|
||||||
.unwrap_or(None)
|
|
||||||
.unwrap_or(false),
|
|
||||||
icase: pairs.get("icase").map_or(None, |x| x.parse().ok()).unwrap_or(false),
|
icase: pairs.get("icase").map_or(None, |x| x.parse().ok()).unwrap_or(false),
|
||||||
|
kind: SeriesKind::from_pairs(&pairs)?,
|
||||||
};
|
};
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
@@ -3030,8 +3016,9 @@ impl ChannelSearchQuery {
|
|||||||
qp.append_pair("nameRegex", &self.name_regex);
|
qp.append_pair("nameRegex", &self.name_regex);
|
||||||
qp.append_pair("sourceRegex", &self.source_regex);
|
qp.append_pair("sourceRegex", &self.source_regex);
|
||||||
qp.append_pair("descriptionRegex", &self.description_regex);
|
qp.append_pair("descriptionRegex", &self.description_regex);
|
||||||
qp.append_pair("channelStatus", &self.channel_status.to_string());
|
|
||||||
qp.append_pair("icase", &self.icase.to_string());
|
qp.append_pair("icase", &self.icase.to_string());
|
||||||
|
drop(qp);
|
||||||
|
self.kind.append_to_url(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ impl From<&ScalarType> for Api1ScalarType {
|
|||||||
A::STRING => B::STRING,
|
A::STRING => B::STRING,
|
||||||
// TODO treat enum as number only
|
// TODO treat enum as number only
|
||||||
A::Enum => B::U16,
|
A::Enum => B::U16,
|
||||||
A::ChannelStatus => todo!("ChannelStatus not in Api1ScalarType"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,10 +174,6 @@ impl EventsStreamRt {
|
|||||||
);
|
);
|
||||||
read_next_values::<EnumVariant>(opts).await
|
read_next_values::<EnumVariant>(opts).await
|
||||||
}
|
}
|
||||||
ScalarType::ChannelStatus => {
|
|
||||||
warn!("read not yet supported {:?} {:?}", shape, scalar_type);
|
|
||||||
err::todoval()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Shape::Wave(_) => match &scalar_type {
|
Shape::Wave(_) => match &scalar_type {
|
||||||
ScalarType::U8 => read_next_values::<Vec<u8>>(opts).await,
|
ScalarType::U8 => read_next_values::<Vec<u8>>(opts).await,
|
||||||
@@ -199,10 +195,6 @@ impl EventsStreamRt {
|
|||||||
warn!("read not yet supported {:?} {:?}", shape, scalar_type);
|
warn!("read not yet supported {:?} {:?}", shape, scalar_type);
|
||||||
err::todoval()
|
err::todoval()
|
||||||
}
|
}
|
||||||
ScalarType::ChannelStatus => {
|
|
||||||
warn!("read not yet supported {:?} {:?}", shape, scalar_type);
|
|
||||||
err::todoval()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
error!("TODO ReadValues add more types");
|
error!("TODO ReadValues add more types");
|
||||||
|
|||||||
Reference in New Issue
Block a user