Factor out taskrun
This commit is contained in:
@@ -3,7 +3,7 @@ use tracing::{error, warn, info, debug, trace};
|
||||
use err::Error;
|
||||
|
||||
pub fn main() {
|
||||
match run(go()) {
|
||||
match taskrun::run(go()) {
|
||||
Ok(k) => {
|
||||
info!("{:?}", k);
|
||||
}
|
||||
@@ -13,19 +13,6 @@ pub fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn run<T, F: std::future::Future<Output=Result<T, Error>>>(f: F) -> Result<T, Error> {
|
||||
tracing_init();
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(12)
|
||||
.max_blocking_threads(256)
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
f.await
|
||||
})
|
||||
}
|
||||
|
||||
async fn go() -> Result<(), Error> {
|
||||
use clap::Clap;
|
||||
use retrieval::cli::{Opts, SubCmd};
|
||||
@@ -40,19 +27,9 @@ async fn go() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn tracing_init() {
|
||||
tracing_subscriber::fmt()
|
||||
//.with_timer(tracing_subscriber::fmt::time::uptime())
|
||||
.with_target(true)
|
||||
.with_thread_names(true)
|
||||
//.with_max_level(tracing::Level::INFO)
|
||||
.with_env_filter(tracing_subscriber::EnvFilter::new("info,retrieval=trace,disk=trace,tokio_postgres=info"))
|
||||
.init();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple_fetch() {
|
||||
run(async {
|
||||
taskrun::run(async {
|
||||
let t1 = chrono::Utc::now();
|
||||
let query = netpod::AggQuerySingleChannel {
|
||||
ksprefix: "daq_swissfel".into(),
|
||||
|
||||
Reference in New Issue
Block a user