Unify service version, postcard, remove error overhead

This commit is contained in:
Dominik Werder
2023-07-20 16:46:40 +02:00
parent df091c0eb7
commit 9314c58a9b
26 changed files with 249 additions and 112 deletions

View File

@@ -1,11 +1,11 @@
[package]
name = "daqbuffer"
version = "0.4.1"
version = "0.4.3-alpha"
authors = ["Dominik Werder <dominik.werder@gmail.com>"]
edition = "2021"
[dependencies]
tokio = { version = "1.18.1", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] }
tokio = { version = "1.22.0", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] }
hyper = "0.14"
http = "0.2"
tracing = "0.1.25"
@@ -20,7 +20,7 @@ serde_json = "1.0"
serde_yaml = "0.9.16"
chrono = "0.4"
url = "2.2.2"
clap = { version = "4.0.22", features = ["derive", "cargo"] }
clap = { version = "4.3.15", features = ["derive", "cargo"] }
lazy_static = "1.4.0"
err = { path = "../err" }
taskrun = { path = "../taskrun" }

View File

@@ -14,6 +14,7 @@ use netpod::DtNano;
use netpod::NodeConfig;
use netpod::NodeConfigCached;
use netpod::ProxyConfig;
use netpod::ServiceVersion;
use tokio::fs::File;
use tokio::io::AsyncReadExt;
@@ -55,9 +56,16 @@ fn parse_ts(s: &str) -> Result<DateTime<Utc>, Error> {
async fn go() -> Result<(), Error> {
let opts = Opts::parse();
let service_version = ServiceVersion {
major: std::env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap_or(0),
minor: std::env!("CARGO_PKG_VERSION_MINOR").parse().unwrap_or(0),
patch: std::env!("CARGO_PKG_VERSION_PATCH").parse().unwrap_or(0),
pre: std::option_env!("CARGO_PKG_VERSION_PRE").map(Into::into),
};
match opts.subcmd {
SubCmd::Retrieval(subcmd) => {
info!("daqbuffer {}", clap::crate_version!());
info!("daqbuffer version {} 0000", clap::crate_version!());
info!("{:?}", service_version);
let mut config_file = File::open(&subcmd.config).await?;
let mut buf = Vec::new();
config_file.read_to_end(&mut buf).await?;
@@ -65,12 +73,12 @@ async fn go() -> Result<(), Error> {
info!("Parsed json config from {}", subcmd.config);
let cfg: Result<NodeConfigCached, Error> = cfg.into();
let cfg = cfg?;
daqbufp2::run_node(cfg).await?;
daqbufp2::run_node(cfg, service_version).await?;
} else if let Ok(cfg) = serde_yaml::from_slice::<NodeConfig>(&buf) {
info!("Parsed yaml config from {}", subcmd.config);
let cfg: Result<NodeConfigCached, Error> = cfg.into();
let cfg = cfg?;
daqbufp2::run_node(cfg).await?;
daqbufp2::run_node(cfg, service_version).await?;
} else {
return Err(Error::with_msg_no_trace(format!(
"can not parse config at {}",
@@ -86,7 +94,7 @@ async fn go() -> Result<(), Error> {
let proxy_config: ProxyConfig =
serde_yaml::from_slice(&buf).map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
info!("Parsed yaml config from {}", subcmd.config);
daqbufp2::run_proxy(proxy_config.clone()).await?;
daqbufp2::run_proxy(proxy_config.clone(), service_version).await?;
}
SubCmd::Client(client) => match client.client_type {
ClientType::Status(opts) => {