Refactor config entry matching
This commit is contained in:
@@ -16,10 +16,11 @@ use netpod::Shape;
|
||||
/// In the future, we can even try to involve time range information for that, but backends like
|
||||
/// old archivers and sf databuffer do not support such lookup.
|
||||
pub async fn chconf_from_scylla_type_backend(channel: &SfDbChannel, ncc: &NodeConfigCached) -> Result<ChConf, Error> {
|
||||
if channel.backend != ncc.node_config.cluster.backend {
|
||||
if channel.backend() != ncc.node_config.cluster.backend {
|
||||
warn!(
|
||||
"mismatched backend {} vs {}",
|
||||
channel.backend, ncc.node_config.cluster.backend
|
||||
channel.backend(),
|
||||
ncc.node_config.cluster.backend
|
||||
);
|
||||
}
|
||||
let backend = channel.backend().into();
|
||||
|
||||
@@ -74,7 +74,7 @@ pub async fn create_connection(db_config: &Database) -> Result<PgClient, Error>
|
||||
pub async fn channel_exists(channel: &SfDbChannel, node_config: &NodeConfigCached) -> Result<bool, Error> {
|
||||
let cl = create_connection(&node_config.node_config.cluster.database).await?;
|
||||
let rows = cl
|
||||
.query("select rowid from channels where name = $1::text", &[&channel.name])
|
||||
.query("select rowid from channels where name = $1::text", &[&channel.name()])
|
||||
.await
|
||||
.err_conv()?;
|
||||
debug!("channel_exists {} rows", rows.len());
|
||||
|
||||
@@ -6,21 +6,21 @@ use netpod::NodeConfigCached;
|
||||
use netpod::SfDbChannel;
|
||||
|
||||
// For sf-databuffer backend, given a Channel, try to complete the information if only id is given.
|
||||
pub async fn sf_databuffer_fetch_channel_by_series(
|
||||
#[allow(unused)]
|
||||
async fn sf_databuffer_fetch_channel_by_series(
|
||||
channel: SfDbChannel,
|
||||
ncc: &NodeConfigCached,
|
||||
) -> Result<SfDbChannel, Error> {
|
||||
info!("sf_databuffer_fetch_channel_by_series");
|
||||
let me = "sf_databuffer_fetch_channel_by_series";
|
||||
info!("{me}");
|
||||
// TODO should not be needed at some point.
|
||||
if channel.backend().is_empty() || channel.name().is_empty() {
|
||||
if let Some(series) = channel.series() {
|
||||
if series < 1 {
|
||||
error!("sf_databuffer_fetch_channel_by_series bad input: {channel:?}");
|
||||
Err(Error::with_msg_no_trace(format!(
|
||||
"sf_databuffer_fetch_channel_by_series bad input: {channel:?}"
|
||||
)))
|
||||
error!("{me} bad input: {channel:?}");
|
||||
Err(Error::with_msg_no_trace(format!("{me} bad input: {channel:?}")))
|
||||
} else {
|
||||
info!("sf_databuffer_fetch_channel_by_series do the lookup");
|
||||
info!("{me} do the lookup");
|
||||
let series = channel
|
||||
.series()
|
||||
.ok_or_else(|| Error::with_msg_no_trace("no series id given"))? as i64;
|
||||
@@ -30,21 +30,18 @@ pub async fn sf_databuffer_fetch_channel_by_series(
|
||||
.await
|
||||
.err_conv()?;
|
||||
if let Some(row) = rows.pop() {
|
||||
info!("sf_databuffer_fetch_channel_by_series got a row {row:?}");
|
||||
info!("{me} got a row {row:?}");
|
||||
let name: String = row.get(0);
|
||||
let channel =
|
||||
SfDbChannel::from_full(ncc.node_config.cluster.backend.clone(), channel.series(), name);
|
||||
info!("sf_databuffer_fetch_channel_by_series return {channel:?}");
|
||||
let channel = SfDbChannel::from_full(&ncc.node_config.cluster.backend, channel.series(), name);
|
||||
info!("{me} return {channel:?}");
|
||||
Ok(channel)
|
||||
} else {
|
||||
info!("sf_databuffer_fetch_channel_by_series nothing found");
|
||||
info!("{me} nothing found");
|
||||
Err(Error::with_msg_no_trace("can not find series"))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Err(Error::with_msg_no_trace(format!(
|
||||
"sf_databuffer_fetch_channel_by_series bad input: {channel:?}"
|
||||
)))
|
||||
Err(Error::with_msg_no_trace(format!("{me} bad input: {channel:?}")))
|
||||
}
|
||||
} else {
|
||||
Ok(channel)
|
||||
|
||||
Reference in New Issue
Block a user