Upgrade to tokio 1.5.0 (#800)

Upgrade to tokio 1.5.0
replaced tokio::sync::mpsc:: with [flume ](https://crates.io/crates/flume) because try_recv was removed
This commit is contained in:
Cheick Keita
2021-04-14 03:07:28 -07:00
committed by GitHub
parent 3f52f34b6a
commit e413aec03d
44 changed files with 683 additions and 356 deletions

View File

@ -42,7 +42,7 @@ dependencies = [
"http",
"log",
"paste",
"reqwest",
"reqwest 0.10.10",
"serde",
"serde_json",
"sm",
@ -478,6 +478,19 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "flume"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11fce69af4d4582ea989e6adfc5c9b81fd2071ff89234e5c14675c82a85217df"
dependencies = [
"futures-core",
"futures-sink",
"nanorand",
"pin-project",
"spinning_top",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -546,9 +559,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1"
checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
dependencies = [
"futures-channel",
"futures-core",
@ -561,9 +574,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939"
checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
dependencies = [
"futures-core",
"futures-sink",
@ -571,15 +584,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94"
checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
[[package]]
name = "futures-executor"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1"
checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d"
dependencies = [
"futures-core",
"futures-task",
@ -588,9 +601,9 @@ dependencies = [
[[package]]
name = "futures-io"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
[[package]]
name = "futures-lite"
@ -609,9 +622,9 @@ dependencies = [
[[package]]
name = "futures-macro"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7"
checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.24",
@ -621,21 +634,21 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3"
checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
[[package]]
name = "futures-task"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80"
checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc"
[[package]]
name = "futures-util"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1"
checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
dependencies = [
"futures-channel",
"futures-core",
@ -669,8 +682,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]
@ -700,12 +715,31 @@ dependencies = [
"http",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tokio 0.2.25",
"tokio-util 0.3.1",
"tracing",
"tracing-futures",
]
[[package]]
name = "h2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc018e188373e2777d0ef2467ebff62a08e66c3f5857b23c8fbec3018210dc00"
dependencies = [
"bytes 1.0.1",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http",
"indexmap",
"slab",
"tokio 1.5.0",
"tokio-util 0.6.6",
"tracing",
]
[[package]]
name = "hashbrown"
version = "0.9.1"
@ -753,6 +787,17 @@ dependencies = [
"http",
]
[[package]]
name = "http-body"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dfb77c123b4e2f72a2069aeae0b4b4949cc7e966df277813fc16347e7549737"
dependencies = [
"bytes 1.0.1",
"http",
"pin-project-lite 0.2.5",
]
[[package]]
name = "httparse"
version = "1.3.5"
@ -781,15 +826,39 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
"h2",
"h2 0.2.7",
"http",
"http-body",
"http-body 0.3.1",
"httparse",
"httpdate",
"itoa",
"pin-project",
"socket2",
"tokio",
"socket2 0.3.19",
"tokio 0.2.25",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "hyper"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bf09f61b52cfcf4c00de50df88ae423d6c02354e385a86341133b5338630ad1"
dependencies = [
"bytes 1.0.1",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.2",
"http",
"http-body 0.4.1",
"httparse",
"httpdate",
"itoa",
"pin-project",
"socket2 0.4.0",
"tokio 1.5.0",
"tower-service",
"tracing",
"want",
@ -802,12 +871,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed"
dependencies = [
"bytes 0.5.6",
"hyper",
"hyper 0.13.10",
"native-tls",
"tokio",
"tokio 0.2.25",
"tokio-tls",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes 1.0.1",
"hyper 0.14.5",
"native-tls",
"tokio 1.5.0",
"tokio-native-tls",
]
[[package]]
name = "idna"
version = "0.2.2"
@ -919,6 +1001,15 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213"
[[package]]
name = "lock_api"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.14"
@ -1010,29 +1101,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "mio-named-pipes"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656"
dependencies = [
"log",
"mio 0.6.23",
"miow 0.3.6",
"winapi 0.3.9",
]
[[package]]
name = "mio-uds"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
dependencies = [
"iovec",
"libc",
"mio 0.6.23",
]
[[package]]
name = "miow"
version = "0.2.2"
@ -1051,10 +1119,19 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [
"socket2",
"socket2 0.3.19",
"winapi 0.3.9",
]
[[package]]
name = "nanorand"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1378b66f7c93a1c0f8464a19bf47df8795083842e5090f4b7305973d5a22d0"
dependencies = [
"getrandom 0.2.2",
]
[[package]]
name = "native-tls"
version = "0.2.7"
@ -1080,7 +1157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670361df1bc2399ee1ff50406a0d422587dd3bb0da596e1978fe8e05dabddf4f"
dependencies = [
"libc",
"socket2",
"socket2 0.3.19",
]
[[package]]
@ -1167,13 +1244,13 @@ dependencies = [
"futures",
"log",
"onefuzz-telemetry",
"reqwest",
"reqwest 0.11.3",
"reqwest-retry",
"serde",
"serde_json",
"storage-queue",
"thiserror",
"tokio",
"tokio 1.5.0",
"url",
"uuid",
]
@ -1183,8 +1260,10 @@ name = "onefuzz-telemetry"
version = "0.1.0"
dependencies = [
"appinsights",
"lazy_static",
"log",
"serde",
"tokio 1.5.0",
"uuid",
]
@ -1227,6 +1306,31 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "parking_lot"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
dependencies = [
"cfg-if 1.0.0",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.9",
]
[[package]]
name = "paste"
version = "0.1.18"
@ -1527,9 +1631,9 @@ dependencies = [
"futures-core",
"futures-util",
"http",
"http-body",
"hyper",
"hyper-tls",
"http-body 0.3.1",
"hyper 0.13.10",
"hyper-tls 0.4.3",
"ipnet",
"js-sys",
"lazy_static",
@ -1542,7 +1646,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio 0.2.25",
"tokio-tls",
"url",
"wasm-bindgen",
@ -1551,6 +1655,41 @@ dependencies = [
"winreg",
]
[[package]]
name = "reqwest"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124"
dependencies = [
"base64",
"bytes 1.0.1",
"encoding_rs",
"futures-core",
"futures-util",
"http",
"http-body 0.4.1",
"hyper 0.14.5",
"hyper-tls 0.5.0",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
"native-tls",
"percent-encoding",
"pin-project-lite 0.2.5",
"serde",
"serde_json",
"serde_urlencoded",
"tokio 1.5.0",
"tokio-native-tls",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"winreg",
]
[[package]]
name = "reqwest-retry"
version = "0.1.0"
@ -1560,7 +1699,7 @@ dependencies = [
"backoff",
"log",
"onefuzz-telemetry",
"reqwest",
"reqwest 0.11.3",
]
[[package]]
@ -1707,6 +1846,12 @@ dependencies = [
"syn 0.15.44",
]
[[package]]
name = "smallvec"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "snafu"
version = "0.6.10"
@ -1739,6 +1884,25 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "socket2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "spinning_top"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bd0ab6b8c375d2d963503b90d3770010d95bc3b5f98036f948dee24bf4e8879"
dependencies = [
"lock_api",
]
[[package]]
name = "storage-queue"
version = "0.1.0"
@ -1749,15 +1913,17 @@ dependencies = [
"base64",
"bytes 0.5.6",
"derivative",
"flume",
"num_cpus",
"queue-file",
"regex",
"reqwest",
"reqwest 0.11.3",
"reqwest-retry",
"serde",
"serde-xml-rs",
"serde_derive",
"serde_json",
"tokio",
"tokio 1.5.0",
"uuid",
"yaque",
]
@ -1902,30 +2068,54 @@ dependencies = [
"futures-core",
"iovec",
"lazy_static",
"libc",
"memchr",
"mio 0.6.23",
"mio-named-pipes",
"mio-uds",
"num_cpus",
"pin-project-lite 0.1.12",
"signal-hook-registry",
"slab",
]
[[package]]
name = "tokio"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83f0c8e7c0addab50b663055baf787d0af7f413a46e6e7fb9559a4e4db7137a5"
dependencies = [
"autocfg",
"bytes 1.0.1",
"libc",
"memchr",
"mio 0.7.9",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite 0.2.5",
"signal-hook-registry",
"tokio-macros",
"winapi 0.3.9",
]
[[package]]
name = "tokio-macros"
version = "0.2.6"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a"
checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.9",
"syn 1.0.60",
]
[[package]]
name = "tokio-native-tls"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"native-tls",
"tokio 1.5.0",
]
[[package]]
name = "tokio-tls"
version = "0.3.1"
@ -1933,7 +2123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343"
dependencies = [
"native-tls",
"tokio",
"tokio 0.2.25",
]
[[package]]
@ -1947,7 +2137,21 @@ dependencies = [
"futures-sink",
"log",
"pin-project-lite 0.1.12",
"tokio",
"tokio 0.2.25",
]
[[package]]
name = "tokio-util"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940a12c99365c31ea8dd9ba04ec1be183ffe4920102bb7122c2f515437601e8e"
dependencies = [
"bytes 1.0.1",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.2.5",
"tokio 1.5.0",
]
[[package]]

View File

@ -10,13 +10,13 @@ license = "MIT"
anyhow = "1.0"
clap = "2.33"
env_logger = "0.8"
futures = "0.3"
reqwest = { version = "0.10", features = ["json", "stream"] }
futures = "0.3.14"
reqwest = { version = "0.11.3", features = ["json", "stream"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
storage-queue = { path = "../agent/storage-queue" }
thiserror = "1.0"
tokio = { version = "0.2", features = ["macros", "rt-threaded", "fs", "process"] }
tokio = { version = "1.5.0", features = ["macros", "rt-multi-thread", "fs", "process"] }
url = { version = "2.2", features = ["serde"] }
reqwest-retry = { path = "../agent/reqwest-retry"}
onefuzz-telemetry = { path = "../agent/onefuzz-telemetry" }

View File

@ -20,7 +20,7 @@ use std::{
};
use tokio::{
runtime::Runtime,
time::{delay_for, Duration},
time::{sleep, Duration},
};
const MINIMUM_NOTIFY_INTERVAL: Duration = Duration::from_secs(120);
@ -37,7 +37,7 @@ async fn run_loop(mut proxy_config: Config) -> Result<()> {
last_notified = Instant::now();
}
delay_for(POLL_INTERVAL).await;
sleep(POLL_INTERVAL).await;
}
}
@ -85,6 +85,6 @@ fn main() -> Result<()> {
let proxy = Config::from_file(config_path)?;
info!("parsed initial config");
let mut rt = Runtime::new()?;
let rt = Runtime::new()?;
rt.block_on(run(proxy))
}

View File

@ -3,7 +3,6 @@
use crate::config::ConfigData;
use anyhow::Result;
use futures::stream::StreamExt;
use std::{collections::HashMap, path::Path};
use tokio::process::Command;
@ -76,9 +75,10 @@ pub async fn update(data: &ConfigData) -> Result<()> {
let configs = build(data);
let mut config_dir = tokio::fs::read_dir(SYSTEMD_CONFIG_DIR).await?;
while let Some(entry) = config_dir.next().await {
let entry = match entry {
Ok(entry) => entry,
loop {
let entry = match config_dir.next_entry().await {
Ok(Some(entry)) => entry,
Ok(None) => break,
Err(err) => {
error!("error listing files {}", err);
continue;