Skip to content

Commit

Permalink
feat: Update tokio to 1.0
Browse files Browse the repository at this point in the history
Followup on mozilla#985 to pull sccache the last little bit into tokio 1.0
  • Loading branch information
Markus Westerlind committed Nov 12, 2021
1 parent 0192fdd commit 1eb5d9c
Show file tree
Hide file tree
Showing 51 changed files with 1,594 additions and 1,609 deletions.
1,468 changes: 629 additions & 839 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ base64 = "0.13"
bincode = "1"
blake3 = "0.3"
byteorder = "1.0"
bytes = "0.5"
bytes = "1"
chrono = { version = "0.4", optional = true }
clap = "2.23.0"
counted-array = "0.1"
Expand All @@ -42,7 +42,7 @@ futures = "0.3"
futures-locks = "0.6"
hmac = { version = "0.10", optional = true }
http = "0.2"
hyper = { version = "0.13", optional = true }
hyper = { version = "0.14", optional = true, features = ["server"] }
hyperx = { version = "0.13", optional = true }
jobserver = "0.1"
jsonwebtoken = { version = "7", optional = true }
Expand All @@ -58,9 +58,9 @@ number_prefix = "0.4"
openssl = { version = "0.10", optional = true }
percent-encoding = { version = "2", optional = true }
rand = "0.7"
redis = { version = "0.17", optional = true, default-features = false, features = ["aio", "tls", "tokio-comp", "tokio-tls-comp"] }
redis = { version = "0.21", optional = true, default-features = false, features = ["aio", "tokio-comp", "tokio-native-tls-comp"] }
regex = "1"
reqwest = { version = "0.10", features = ["json", "blocking"], optional = true }
reqwest = { version = "0.11", features = ["json", "blocking"], optional = true }
retry = "1"
ring = { version = "0.16", optional = true, features = ["std"] }
sha-1 = { version = "0.9", optional = true }
Expand All @@ -71,10 +71,10 @@ serde_json = "1.0"
strip-ansi-escapes = "0.1"
tar = "0.4"
tempfile = "3"
tokio = { version = "0.2", features = ["rt-threaded", "blocking", "io-util", "time", "uds", "tcp", "process", "macros"] }
tokio-serde = "0.6"
tokio-util = { version = "0.3", features = ["codec"] }
tower = "0.3"
tokio = { version = "1", features = ["rt-multi-thread", "io-util", "time", "net", "process", "macros"] }
tokio-serde = "0.8"
tokio-util = { version = "0.6", features = ["codec"] }
tower = "0.4"
toml = "0.5"
untrusted = { version = "0.7", optional = true }
url = { version = "2", optional = true }
Expand Down Expand Up @@ -106,7 +106,7 @@ selenium-rs = "0.1"
daemonize = "0.4"

[target.'cfg(windows)'.dependencies]
parity-tokio-ipc = "0.8"
parity-tokio-ipc = "0.9"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
Expand Down
16 changes: 7 additions & 9 deletions src/azure/blobstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::azure::credentials::*;
use std::{fmt, str::FromStr};

use hmac::{Hmac, Mac, NewMac};
use hyperx::header;
use md5::{Digest, Md5};
use reqwest::Url;
use reqwest::{header::HeaderValue, Client, Method, Request};
use reqwest::{header::HeaderValue, Client, Method, Request, Url};
use sha2::Sha256;
use std::fmt;
use std::str::FromStr;

use crate::errors::*;
use crate::util::HeadersExt;
use crate::{azure::credentials::*, errors::*, util::HeadersExt};

const BLOB_API_VERSION: &str = "2017-04-17";

Expand Down Expand Up @@ -266,9 +263,10 @@ fn canonicalize_resource(uri: &Url, account_name: &str) -> String {

#[cfg(test)]
mod test {
use super::*;
use tokio::runtime::Runtime;

use super::*;

#[test]
fn test_signing() {
// Test values copied from https://github.com/MindFlavor/AzureSDKForRust,
Expand Down Expand Up @@ -320,7 +318,7 @@ mod test {
container_name.to_string(),
);

let mut runtime = Runtime::new().unwrap();
let runtime = Runtime::new().unwrap();

let container = BlobContainer::new(creds.azure_blob_endpoint(), container_name).unwrap();

Expand Down
3 changes: 1 addition & 2 deletions src/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
mod blobstore;
mod credentials;

pub use crate::azure::blobstore::*;
pub use crate::azure::credentials::*;
pub use crate::azure::{blobstore::*, credentials::*};
27 changes: 15 additions & 12 deletions src/bin/sccache-dist/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::{
collections::{hash_map, HashMap},
fs, io, iter,
path::{self, Path, PathBuf},
process::{ChildStdin, Command, Output, Stdio},
sync::Mutex,
time::Instant,
};

use anyhow::{anyhow, bail, Context, Error, Result};
use flate2::read::GzDecoder;
use libmount::Overlay;
use sccache::dist::{
BuildResult, BuilderIncoming, CompileCommand, InputsReader, OutputData, ProcessOutput, TcCache,
Toolchain,
use sccache::{
dist::{
BuildResult, BuilderIncoming, CompileCommand, InputsReader, OutputData, ProcessOutput,
TcCache, Toolchain,
},
lru_disk_cache::Error as LruError,
};
use sccache::lru_disk_cache::Error as LruError;
use std::collections::{hash_map, HashMap};
use std::fs;
use std::io;
use std::iter;
use std::path::{self, Path, PathBuf};
use std::process::{ChildStdin, Command, Output, Stdio};
use std::sync::Mutex;
use std::time::Instant;
use version_compare::Version;

trait CommandExt {
Expand Down
42 changes: 23 additions & 19 deletions src/bin/sccache-dist/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,32 @@ extern crate syslog;
extern crate tar;
extern crate void;

use std::{
collections::{btree_map, BTreeMap, HashMap, HashSet},
env, io,
net::SocketAddr,
path::Path,
sync::{
atomic::{AtomicUsize, Ordering},
Mutex, MutexGuard,
},
time::{Duration, Instant},
};

use anyhow::{bail, Context, Error, Result};
use clap::{App, Arg, ArgMatches, SubCommand};
use rand::{rngs::OsRng, RngCore};
use sccache::config::{
scheduler as scheduler_config, server as server_config, INSECURE_DIST_CLIENT_TOKEN,
};
use sccache::dist::{
self, AllocJobResult, AssignJobResult, BuilderIncoming, CompileCommand, HeartbeatServerResult,
InputsReader, JobAlloc, JobAuthorizer, JobComplete, JobId, JobState, RunJobResult,
SchedulerIncoming, SchedulerOutgoing, SchedulerStatusResult, ServerId, ServerIncoming,
ServerNonce, ServerOutgoing, SubmitToolchainResult, TcCache, Toolchain, ToolchainReader,
UpdateJobStateResult,
use sccache::{
config::{scheduler as scheduler_config, server as server_config, INSECURE_DIST_CLIENT_TOKEN},
dist::{
self, AllocJobResult, AssignJobResult, BuilderIncoming, CompileCommand,
HeartbeatServerResult, InputsReader, JobAlloc, JobAuthorizer, JobComplete, JobId, JobState,
RunJobResult, SchedulerIncoming, SchedulerOutgoing, SchedulerStatusResult, ServerId,
ServerIncoming, ServerNonce, ServerOutgoing, SubmitToolchainResult, TcCache, Toolchain,
ToolchainReader, UpdateJobStateResult,
},
util::daemonize,
};
use sccache::util::daemonize;
use std::collections::{btree_map, BTreeMap, HashMap, HashSet};
use std::env;
use std::io;
use std::net::SocketAddr;
use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Mutex, MutexGuard};
use std::time::{Duration, Instant};
use syslog::Facility;

mod build;
Expand Down Expand Up @@ -433,7 +437,7 @@ fn init_logging() {
if env::var("RUST_LOG").is_ok() {
match env_logger::try_init() {
Ok(_) => (),
Err(e) => panic!(format!("Failed to initalize logging: {:?}", e)),
Err(e) => panic!("Failed to initalize logging: {:?}", e),
}
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/bin/sccache-dist/token_check.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use crate::jwt;
use std::{
collections::HashMap,
result::Result as StdResult,
sync::Mutex,
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};

use anyhow::{bail, Context, Result};
use sccache::dist::http::{ClientAuthCheck, ClientVisibleMsg};
use sccache::util::RequestExt;
use std::collections::HashMap;
use std::result::Result as StdResult;
use std::sync::Mutex;
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use sccache::{
dist::http::{ClientAuthCheck, ClientVisibleMsg},
util::RequestExt,
};

use crate::jwt;

// https://auth0.com/docs/jwks
#[derive(Debug, Serialize, Deserialize)]
Expand Down
17 changes: 10 additions & 7 deletions src/cache/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::azure::BlobContainer;
use crate::azure::*;
use crate::cache::{Cache, CacheRead, CacheWrite, Storage};
use std::io;
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::{
io,
sync::Arc,
time::{Duration, Instant},
};

use crate::errors::*;
use crate::{
azure::{BlobContainer, *},
cache::{Cache, CacheRead, CacheWrite, Storage},
errors::*,
};

pub struct AzureBlobCache {
container: Arc<BlobContainer>,
Expand Down
36 changes: 19 additions & 17 deletions src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "gcs")]
use std::fs::File;
use std::{
fmt, fs,
io::{self, Cursor, Read, Seek, Write},
path::{Path, PathBuf},
sync::Arc,
time::Duration,
};

use tempfile::NamedTempFile;
use zip::{write::FileOptions, CompressionMethod, ZipArchive, ZipWriter};

#[cfg(feature = "azure")]
use crate::cache::azure::AzureBlobCache;
use crate::cache::disk::DiskCache;
#[cfg(feature = "gcs")]
use crate::cache::gcs::{self, GCSCache, GCSCredentialProvider, RWMode, ServiceAccountInfo};
#[cfg(feature = "memcached")]
Expand All @@ -23,20 +35,11 @@ use crate::cache::memcached::MemcachedCache;
use crate::cache::redis::RedisCache;
#[cfg(feature = "s3")]
use crate::cache::s3::S3Cache;
use crate::config::{self, CacheType, Config};
use std::fmt;
use std::fs;
#[cfg(feature = "gcs")]
use std::fs::File;
use std::io::{self, Cursor, Read, Seek, Write};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Duration;
use tempfile::NamedTempFile;
use zip::write::FileOptions;
use zip::{CompressionMethod, ZipArchive, ZipWriter};

use crate::errors::*;
use crate::{
cache::disk::DiskCache,
config::{self, CacheType, Config},
errors::*,
};

#[cfg(unix)]
fn get_file_mode(file: &fs::File) -> Result<Option<u32>> {
Expand All @@ -52,8 +55,7 @@ fn get_file_mode(_file: &fs::File) -> Result<Option<u32>> {

#[cfg(unix)]
fn set_file_mode(path: &Path, mode: u32) -> Result<()> {
use std::fs::Permissions;
use std::os::unix::fs::PermissionsExt;
use std::{fs::Permissions, os::unix::fs::PermissionsExt};
let p = Permissions::from_mode(mode);
fs::set_permissions(path, p)?;
Ok(())
Expand Down
19 changes: 11 additions & 8 deletions src/cache/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::cache::{Cache, CacheRead, CacheWrite, Storage};
use crate::lru_disk_cache::Error as LruError;
use crate::lru_disk_cache::LruDiskCache;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use std::{
ffi::OsStr,
path::{Path, PathBuf},
sync::{Arc, Mutex},
time::{Duration, Instant},
};

use crate::errors::*;
use crate::{
cache::{Cache, CacheRead, CacheWrite, Storage},
errors::*,
lru_disk_cache::{Error as LruError, LruDiskCache},
};

/// A cache that stores entries at local disk paths.
#[derive(Clone)]
Expand Down
14 changes: 8 additions & 6 deletions src/cache/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@

use std::{fmt, io, sync::Arc, time};

use crate::{
cache::{Cache, CacheRead, CacheWrite, Storage},
errors::*,
util::HeadersExt,
};
use hyper::Method;
use hyperx::header::{Authorization, Bearer, ContentLength, ContentType};
use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
use reqwest::{Client, Request};
use serde::de;
use url::form_urlencoded;

use crate::{
cache::{Cache, CacheRead, CacheWrite, Storage},
errors::*,
util::HeadersExt,
};

/// Lifted from the url crate
/// https://url.spec.whatwg.org/#fragment-percent-encode-set
const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
Expand Down Expand Up @@ -508,9 +509,10 @@ impl Storage for GCSCache {

#[tokio::test]
async fn test_gcs_credential_provider() {
use futures::{FutureExt, TryFutureExt};
use std::convert::Infallible;

use futures::{FutureExt, TryFutureExt};

const EXPIRE_TIME: &str = "3000-01-01T00:00:00.0Z";
let addr = ([127, 0, 0, 1], 3000).into();
let make_service = hyper::service::make_service_fn(|_socket| async {
Expand Down

0 comments on commit 1eb5d9c

Please sign in to comment.