Rename SfDbChannel
This commit is contained in:
@@ -2,9 +2,9 @@ use crate::ErrConv;
|
||||
use err::Error;
|
||||
use netpod::log::*;
|
||||
use netpod::ChConf;
|
||||
use netpod::Channel;
|
||||
use netpod::NodeConfigCached;
|
||||
use netpod::ScalarType;
|
||||
use netpod::SfDbChannel;
|
||||
use netpod::Shape;
|
||||
|
||||
/// It is an unsolved question as to how we want to uniquely address channels.
|
||||
@@ -15,7 +15,7 @@ use netpod::Shape;
|
||||
/// Otherwise we try to uniquely identify the series id from the given information.
|
||||
/// 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: &Channel, ncc: &NodeConfigCached) -> Result<ChConf, Error> {
|
||||
pub async fn chconf_from_scylla_type_backend(channel: &SfDbChannel, ncc: &NodeConfigCached) -> Result<ChConf, Error> {
|
||||
if channel.backend != ncc.node_config.cluster.backend {
|
||||
warn!(
|
||||
"mismatched backend {} vs {}",
|
||||
|
||||
@@ -12,7 +12,7 @@ use err::Error;
|
||||
use err::Res2;
|
||||
use netpod::log::*;
|
||||
use netpod::TableSizes;
|
||||
use netpod::{Channel, Database, NodeConfigCached};
|
||||
use netpod::{Database, NodeConfigCached, SfDbChannel};
|
||||
use netpod::{ScalarType, Shape};
|
||||
use pg::{Client as PgClient, NoTls};
|
||||
use std::sync::Arc;
|
||||
@@ -71,7 +71,7 @@ pub async fn create_connection(db_config: &Database) -> Result<PgClient, Error>
|
||||
Ok(cl)
|
||||
}
|
||||
|
||||
pub async fn channel_exists(channel: &Channel, node_config: &NodeConfigCached) -> Result<bool, 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])
|
||||
@@ -155,7 +155,7 @@ pub async fn insert_channel(name: String, facility: i64, dbc: &PgClient) -> Resu
|
||||
}
|
||||
|
||||
// Currently only for scylla type backends
|
||||
pub async fn find_series(channel: &Channel, pgclient: Arc<PgClient>) -> Result<(u64, ScalarType, Shape), Error> {
|
||||
pub async fn find_series(channel: &SfDbChannel, pgclient: Arc<PgClient>) -> Result<(u64, ScalarType, Shape), Error> {
|
||||
info!("find_series channel {:?}", channel);
|
||||
let rows = if let Some(series) = channel.series() {
|
||||
let q = "select series, facility, channel, scalar_type, shape_dims from series_by_channel where series = $1";
|
||||
@@ -194,7 +194,7 @@ pub async fn find_series(channel: &Channel, pgclient: Arc<PgClient>) -> Result<(
|
||||
|
||||
// Currently only for sf-databuffer type backends
|
||||
// Note: we currently treat the channels primary key as series-id for sf-databuffer type backends.
|
||||
pub async fn find_series_sf_databuffer(channel: &Channel, pgclient: Arc<PgClient>) -> Res2<u64> {
|
||||
pub async fn find_series_sf_databuffer(channel: &SfDbChannel, pgclient: Arc<PgClient>) -> Res2<u64> {
|
||||
info!("find_series channel {:?}", channel);
|
||||
let sql = "select rowid from facilities where name = $1";
|
||||
let rows = pgclient.query(sql, &[&channel.backend()]).await.err_conv()?;
|
||||
|
||||
@@ -2,11 +2,14 @@ use crate::create_connection;
|
||||
use crate::ErrConv;
|
||||
use err::Error;
|
||||
use netpod::log::*;
|
||||
use netpod::Channel;
|
||||
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(channel: Channel, ncc: &NodeConfigCached) -> Result<Channel, Error> {
|
||||
pub async fn sf_databuffer_fetch_channel_by_series(
|
||||
channel: SfDbChannel,
|
||||
ncc: &NodeConfigCached,
|
||||
) -> Result<SfDbChannel, Error> {
|
||||
info!("sf_databuffer_fetch_channel_by_series");
|
||||
// TODO should not be needed at some point.
|
||||
if channel.backend().is_empty() || channel.name().is_empty() {
|
||||
@@ -29,7 +32,7 @@ pub async fn sf_databuffer_fetch_channel_by_series(channel: Channel, ncc: &NodeC
|
||||
if let Some(row) = rows.pop() {
|
||||
info!("sf_databuffer_fetch_channel_by_series got a row {row:?}");
|
||||
let name: String = row.get(0);
|
||||
let channel = Channel {
|
||||
let channel = SfDbChannel {
|
||||
series: channel.series,
|
||||
backend: ncc.node_config.cluster.backend.clone(),
|
||||
name,
|
||||
|
||||
@@ -483,8 +483,8 @@ async fn update_db_with_channel_config(
|
||||
} else {
|
||||
return Ok(UpdateChannelConfigResult::NotFound);
|
||||
};
|
||||
if meta.len() > 8 * 1024 * 1024 {
|
||||
return Err(Error::with_msg("meta data too long"));
|
||||
if meta.len() > 40 * 1024 * 1024 {
|
||||
return Err(Error::with_msg("meta data too long {meta:?}"));
|
||||
}
|
||||
let rows = dbc
|
||||
.query(
|
||||
|
||||
Reference in New Issue
Block a user