diff --git a/registry/CHANGELOG.md b/registry/CHANGELOG.md index 37e577d..d4c5981 100644 --- a/registry/CHANGELOG.md +++ b/registry/CHANGELOG.md @@ -8,17 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - Support deprecating and yanking packages by @daimond113 +- Add yanking & deprecating to registry by @daimond113 +- Log more information about configured auth & storage by @daimond113 ### Changed - Asyncify blocking operations by @daimond113 +### Performance +- Switch to using a `RwLock` over a `Mutex` to store repository data by @daimond113 + ## [0.1.2] ### Changed - Update to pesde lib API changes by @daimond113 ## [0.1.1] - 2024-12-19 ### Changed -- Switch to traccing for logging by @daimond113 +- Switch to tracing for logging by @daimond113 ## [0.1.0] - 2024-12-14 ### Added diff --git a/registry/src/endpoints/deprecate_version.rs b/registry/src/endpoints/deprecate_version.rs index 432780a..64b6e71 100644 --- a/registry/src/endpoints/deprecate_version.rs +++ b/registry/src/endpoints/deprecate_version.rs @@ -36,7 +36,7 @@ pub async fn deprecate_package_version( String::new() }; let name = path.into_inner(); - let source = app_state.source.lock().await; + let source = app_state.source.write().await; let Some(scope_info) = read_scope_info(&app_state, name.scope(), &source).await? else { return Ok(HttpResponse::NotFound().finish()); diff --git a/registry/src/endpoints/package_version.rs b/registry/src/endpoints/package_version.rs index 2c52439..d212301 100644 --- a/registry/src/endpoints/package_version.rs +++ b/registry/src/endpoints/package_version.rs @@ -23,7 +23,7 @@ pub async fn get_package_version( ) -> Result { let (name, version, target) = path.into_inner(); - let Some(file) = read_package(&app_state, &name, &*app_state.source.lock().await).await? else { + let Some(file) = read_package(&app_state, &name, &*app_state.source.read().await).await? else { return Ok(HttpResponse::NotFound().finish()); }; diff --git a/registry/src/endpoints/package_versions.rs b/registry/src/endpoints/package_versions.rs index 2a7b180..a792b3a 100644 --- a/registry/src/endpoints/package_versions.rs +++ b/registry/src/endpoints/package_versions.rs @@ -13,7 +13,7 @@ pub async fn get_package_versions( ) -> Result { let name = path.into_inner(); - let Some(file) = read_package(&app_state, &name, &*app_state.source.lock().await).await? else { + let Some(file) = read_package(&app_state, &name, &*app_state.source.read().await).await? else { return Ok(HttpResponse::NotFound().finish()); }; diff --git a/registry/src/endpoints/publish_version.rs b/registry/src/endpoints/publish_version.rs index bb342b9..1356c1e 100644 --- a/registry/src/endpoints/publish_version.rs +++ b/registry/src/endpoints/publish_version.rs @@ -52,7 +52,7 @@ pub async fn publish_package( bytes: Bytes, user_id: web::ReqData, ) -> Result { - let source = app_state.source.lock().await; + let source = app_state.source.write().await; source .refresh(&RefreshOptions { project: app_state.project.clone(), diff --git a/registry/src/endpoints/search.rs b/registry/src/endpoints/search.rs index c063fa1..3ba24a8 100644 --- a/registry/src/endpoints/search.rs +++ b/registry/src/endpoints/search.rs @@ -52,7 +52,7 @@ pub async fn search_packages( ) .unwrap(); - let source = app_state.source.lock().await; + let source = app_state.source.read().await; let repo = gix::open(source.path(&app_state.project))?; let tree = root_tree(&repo)?; diff --git a/registry/src/endpoints/yank_version.rs b/registry/src/endpoints/yank_version.rs index 0be0769..c882d77 100644 --- a/registry/src/endpoints/yank_version.rs +++ b/registry/src/endpoints/yank_version.rs @@ -20,7 +20,7 @@ pub async fn yank_package_version( ) -> Result { let yanked = request.method() != Method::DELETE; let (name, version, target) = path.into_inner(); - let source = app_state.source.lock().await; + let source = app_state.source.write().await; let Some(scope_info) = read_scope_info(&app_state, name.scope(), &source).await? else { return Ok(HttpResponse::NotFound().finish()); diff --git a/registry/src/main.rs b/registry/src/main.rs index 48583fa..8d571d3 100644 --- a/registry/src/main.rs +++ b/registry/src/main.rs @@ -47,7 +47,7 @@ pub fn make_reqwest() -> reqwest::Client { } pub struct AppState { - pub source: tokio::sync::Mutex, + pub source: tokio::sync::RwLock, pub project: Project, pub storage: Storage, pub auth: Auth, @@ -134,7 +134,7 @@ async fn run() -> std::io::Result<()> { tracing::info!("auth: {auth}"); auth }, - source: tokio::sync::Mutex::new(source), + source: tokio::sync::RwLock::new(source), project, search_reader,