mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-23 18:56:30 +00:00
Compare commits
2 commits
f6ba95c070
...
dfcdf31c72
Author | SHA1 | Date | |
---|---|---|---|
|
dfcdf31c72 | ||
|
85a077e80d |
4 changed files with 19 additions and 13 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -538,6 +538,12 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error_reporter"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31ae425815400e5ed474178a7a22e275a9687086a12ca63ec793ff292d8fdae8"
|
||||
|
||||
[[package]]
|
||||
name = "faster-hex"
|
||||
version = "0.9.0"
|
||||
|
@ -2697,6 +2703,7 @@ dependencies = [
|
|||
"crates-index",
|
||||
"derive_more",
|
||||
"dotenvy",
|
||||
"error_reporter",
|
||||
"font-awesome-as-a-crate",
|
||||
"futures-util",
|
||||
"gix",
|
||||
|
@ -2705,6 +2712,7 @@ dependencies = [
|
|||
"lru_time_cache",
|
||||
"maud",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"pulldown-cmark",
|
||||
"relative-path",
|
||||
"reqwest",
|
||||
|
|
|
@ -24,10 +24,12 @@ derive_more = "0.99"
|
|||
dotenvy = "0.15"
|
||||
font-awesome-as-a-crate = "0.3"
|
||||
futures-util = { version = "0.3", default-features = false, features = ["std"] }
|
||||
error_reporter = "1"
|
||||
indexmap = { version = "2", features = ["serde"] }
|
||||
lru_time_cache = "0.11"
|
||||
maud = "0.26"
|
||||
once_cell = "1"
|
||||
parking_lot = "0.12"
|
||||
pulldown-cmark = "0.11"
|
||||
relative-path = { version = "1", features = ["serde"] }
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
|
|
|
@ -56,7 +56,7 @@ fn init_tracing_subscriber() {
|
|||
.init();
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
dotenvy::dotenv().ok();
|
||||
init_tracing_subscriber();
|
||||
|
@ -98,10 +98,9 @@ async fn main() {
|
|||
.client_request_timeout(Duration::from_secs(5))
|
||||
.finish(move |req: Request| {
|
||||
let app = app.clone();
|
||||
let path = req.path().to_owned();
|
||||
|
||||
async move {
|
||||
let path = req.path().to_owned();
|
||||
|
||||
app.handle(req)
|
||||
.instrument(tracing::info_span!("@", %path))
|
||||
.await
|
||||
|
|
|
@ -26,9 +26,7 @@ impl ManagedIndex {
|
|||
}
|
||||
|
||||
pub fn crate_(&self, crate_name: CrateName) -> Option<Crate> {
|
||||
let index = self.index.lock().unwrap();
|
||||
|
||||
index.crate_(crate_name.as_ref())
|
||||
self.index.lock().unwrap().crate_(crate_name.as_ref())
|
||||
}
|
||||
|
||||
pub async fn refresh_at_interval(&self, update_interval: Duration) {
|
||||
|
@ -38,22 +36,21 @@ impl ManagedIndex {
|
|||
loop {
|
||||
if let Err(err) = self.refresh().await {
|
||||
tracing::error!(
|
||||
"failed refreshing the crates.io-index, the operation will be retried: {err}"
|
||||
"failed refreshing the crates.io-index, the operation will be retried: {}",
|
||||
error_reporter::Report::new(err),
|
||||
);
|
||||
}
|
||||
update_interval.tick().await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn refresh(&self) -> Result<()> {
|
||||
async fn refresh(&self) -> Result<(), crates_index::Error> {
|
||||
let index = Arc::clone(&self.index);
|
||||
|
||||
spawn_blocking(move || {
|
||||
let mut index = index.lock().unwrap();
|
||||
spawn_blocking(move || index.lock().unwrap().update())
|
||||
.await
|
||||
.expect("blocking index update task should never panic")?;
|
||||
|
||||
index.update()
|
||||
})
|
||||
.await??;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue