mirror of
https://github.com/modrinth/code.git
synced 2026-08-28 02:24:56 +00:00
feat(app-backend): key circuit breaker by URI path pattern (#6383)
* feat(app-lib): split `FetchFence` on base URI path * chore: fmt * fix(app-lib): fix test timing
This commit is contained in:
@@ -88,6 +88,7 @@ pub async fn download_version_info(
|
||||
&version.url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&st.api_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
@@ -99,6 +100,7 @@ pub async fn download_version_info(
|
||||
&loader.url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&st.api_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
@@ -149,6 +151,7 @@ pub async fn download_client(
|
||||
&client_download.url,
|
||||
Some(&client_download.sha1),
|
||||
None,
|
||||
None,
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
@@ -189,6 +192,7 @@ pub async fn download_assets_index(
|
||||
&version.asset_index.url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
@@ -239,7 +243,7 @@ pub async fn download_assets(
|
||||
async {
|
||||
if !resource_path.exists() || force {
|
||||
let resource = fetch_cell
|
||||
.get_or_try_init(|| fetch(&url, Some(hash), None, &st.fetch_semaphore, &st.pool))
|
||||
.get_or_try_init(|| fetch(&url, Some(hash), None, None, &st.fetch_semaphore, &st.pool))
|
||||
.await?;
|
||||
write(&resource_path, resource, &st.io_semaphore).await?;
|
||||
tracing::trace!("Fetched asset with hash {hash}");
|
||||
@@ -253,7 +257,7 @@ pub async fn download_assets(
|
||||
|
||||
if with_legacy && !resource_path.exists() || force {
|
||||
let resource = fetch_cell
|
||||
.get_or_try_init(|| fetch(&url, Some(hash), None, &st.fetch_semaphore, &st.pool))
|
||||
.get_or_try_init(|| fetch(&url, Some(hash), None, None, &st.fetch_semaphore, &st.pool))
|
||||
.await?;
|
||||
write(&resource_path, resource, &st.io_semaphore).await?;
|
||||
tracing::trace!("Fetched legacy asset with hash {hash}");
|
||||
@@ -328,6 +332,7 @@ pub async fn download_libraries(
|
||||
&native.url,
|
||||
Some(&native.sha1),
|
||||
None,
|
||||
None,
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
@@ -373,6 +378,7 @@ pub async fn download_libraries(
|
||||
&artifact.url,
|
||||
Some(&artifact.sha1),
|
||||
None,
|
||||
None,
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
@@ -409,8 +415,15 @@ pub async fn download_libraries(
|
||||
// failed download here is not a fatal condition.
|
||||
//
|
||||
// See DEV-479.
|
||||
match fetch(&url, None, None, &st.fetch_semaphore, &st.pool)
|
||||
.await
|
||||
match fetch(
|
||||
&url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(bytes) => {
|
||||
write(&path, &bytes, &st.io_semaphore).await?;
|
||||
@@ -470,6 +483,7 @@ pub async fn download_log_config(
|
||||
&log_download.url,
|
||||
Some(&log_download.sha1),
|
||||
None,
|
||||
None,
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user