introduce new runtime tokio helpers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2020-01-20 12:52:22 +01:00
parent aac9dbf635
commit d973aa827c
13 changed files with 173 additions and 43 deletions

View File

@ -57,7 +57,7 @@ async fn run() -> Result<(), Error> {
#[tokio::main]
async fn main() {
if let Err(err) = run().await {
if let Err(err) = proxmox_backup::tools::runtime::main(run()) {
eprintln!("ERROR: {}", err);
}
println!("DONE");

View File

@ -69,8 +69,11 @@ fn send_request(
})
}
#[tokio::main]
async fn main() -> Result<(), Error> {
fn main() -> Result<(), Error> {
proxmox_backup::tools::runtime::main(run())
}
async fn run() -> Result<(), Error> {
let start = std::time::SystemTime::now();

View File

@ -67,8 +67,11 @@ fn send_request(
})
}
#[tokio::main]
async fn main() -> Result<(), Error> {
fn main() -> Result<(), Error> {
proxmox_backup::tools::runtime::main(run())
}
async fn run() -> Result<(), Error> {
let start = std::time::SystemTime::now();
let conn =

View File

@ -10,8 +10,11 @@ use proxmox_backup::configdir;
// Simple H2 server to test H2 speed with h2s-client.rs
#[tokio::main]
async fn main() -> Result<(), Error> {
fn main() -> Result<(), Error> {
proxmox_backup::tools::runtime::main(run())
}
async fn run() -> Result<(), Error> {
let key_path = configdir!("/proxy.key");
let cert_path = configdir!("/proxy.pem");

View File

@ -8,8 +8,11 @@ use tokio::io::{AsyncRead, AsyncWrite};
use proxmox_backup::client::pipe_to_stream::PipeToSendStream;
#[tokio::main]
async fn main() -> Result<(), Error> {
fn main() -> Result<(), Error> {
proxmox_backup::tools::runtime::main(run())
}
async fn run() -> Result<(), Error> {
let mut listener = TcpListener::bind(std::net::SocketAddr::from(([127,0,0,1], 8008))).await?;
println!("listening on {:?}", listener.local_addr());

View File

@ -13,9 +13,8 @@ use proxmox_backup::auth_helpers::*;
use proxmox_backup::config;
use proxmox_backup::buildcfg;
#[tokio::main]
async fn main() {
if let Err(err) = run().await {
fn main() {
if let Err(err) = proxmox_backup::tools::runtime::main(run()) {
eprintln!("Error: {}", err);
std::process::exit(-1);
}

View File

@ -15,9 +15,8 @@ use proxmox_backup::tools::daemon;
use proxmox_backup::server::{ApiConfig, rest::*};
use proxmox_backup::auth_helpers::*;
#[tokio::main]
async fn main() {
if let Err(err) = run().await {
fn main() {
if let Err(err) = proxmox_backup::tools::runtime::main(run()) {
eprintln!("Error: {}", err);
std::process::exit(-1);
}

View File

@ -12,9 +12,8 @@ use proxmox_backup::backup::*;
//
// Note: I can currently get about 830MB/s
#[tokio::main]
async fn main() {
if let Err(err) = run().await {
fn main() {
if let Err(err) = proxmox_backup::tools::runtime::main(run()) {
panic!("ERROR: {}", err);
}
}

View File

@ -21,9 +21,8 @@ async fn upload_speed() -> Result<usize, Error> {
Ok(res)
}
#[tokio::main]
async fn main() {
match upload_speed().await {
fn main() {
match proxmox_backup::tools::runtime::main(upload_speed()) {
Ok(mbs) => {
println!("average upload speed: {} MB/s", mbs);
}