Reduce helper apis

This commit is contained in:
Dominik Werder
2022-12-13 09:55:45 +01:00
parent dfadb530d5
commit c566b5a336
11 changed files with 77 additions and 359 deletions
+6 -8
View File
@@ -10,22 +10,20 @@ path = "src/dbconn.rs"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.20.1", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] }
tokio = { version = "1.23.0", features = ["time"] }
tokio-postgres = { version = "0.7.7", features = ["with-chrono-0_4", "with-serde_json-1"] }
tracing = "0.1.25"
crc32fast = "1.2.1"
arrayref = "0.3.6"
tracing = "0.1.37"
crc32fast = "1.3.2"
byteorder = "1.4"
futures-core = "0.3.24"
futures-util = "0.3.24"
bytes = "1.2"
futures-util = "0.3.25"
bytes = "1.3"
pin-project = "1"
#async-channel = "1"
#dashmap = "3"
scylla = "0.6.1"
async-channel = "1.6"
chrono = "0.4"
regex = "1.5.4"
regex = "1.7.0"
err = { path = "../err" }
netpod = { path = "../netpod" }
parse = { path = "../parse" }
+1 -8
View File
@@ -72,14 +72,7 @@ pub async fn chconf_from_database(channel: &Channel, ncc: &NodeConfigCached) ->
}
// TODO use a common already running worker pool for these queries:
let dbconf = &ncc.node_config.cluster.database;
let dburl = format!(
"postgresql://{}:{}@{}:{}/{}",
dbconf.user, dbconf.pass, dbconf.host, dbconf.port, dbconf.name
);
let (pgclient, pgconn) = tokio_postgres::connect(&dburl, tokio_postgres::NoTls)
.await
.err_conv()?;
tokio::spawn(pgconn);
let pgclient = crate::create_connection(dbconf).await?;
if let Some(series) = channel.series() {
let res = pgclient
.query(
+1
View File
@@ -49,6 +49,7 @@ pub async fn delay_io_medium() {
}
pub async fn create_connection(db_config: &Database) -> Result<Client, Error> {
// TODO use a common already running worker pool for these queries:
let d = db_config;
let uri = format!("postgresql://{}:{}@{}:{}/{}", d.user, d.pass, d.host, 5432, d.name);
let (cl, conn) = tokio_postgres::connect(&uri, NoTls)
+1 -2
View File
@@ -2,8 +2,7 @@ use crate::{create_connection, delay_io_medium, delay_io_short, ErrConv};
use async_channel::{bounded, Receiver};
use chrono::{DateTime, Utc};
use err::Error;
use futures_core::Stream;
use futures_util::FutureExt;
use futures_util::{FutureExt, Stream};
use netpod::log::*;
use netpod::{Database, NodeConfigCached};
use parse::channelconfig::NErr;