Skip to content

Commit

Permalink
Add PARALLEL_PACKAGE_FILES_GETS = 32
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic committed Feb 14, 2024
1 parent 3a44409 commit c5293fc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/providers/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ use reqwest::{header, Certificate};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use time::{Duration, OffsetDateTime};
use tokio::sync::Semaphore;
use tracing::{debug, info_span, instrument, Instrument};
use url::Url;

/// Number of `package_files` GETs to do in parallel.
const PARALLEL_PACKAGE_FILES_GETS: usize = 32;

pub struct Gitlab {
client: reqwest::Client,
base_url: Url,
Expand Down Expand Up @@ -174,6 +178,7 @@ impl super::PackageProvider for Gitlab {
uri
});

let fetch_concurrency = Semaphore::new(PARALLEL_PACKAGE_FILES_GETS);
let futures = FuturesUnordered::new();

while let Some(uri) = next_uri.take() {
Expand Down Expand Up @@ -204,9 +209,12 @@ impl super::PackageProvider for Gitlab {
for release in res {
let this = Arc::clone(&self);
let do_as = Arc::clone(do_as);
let fetch_concurrency = &fetch_concurrency;

futures.push(
async move {
let _guard = fetch_concurrency.acquire().await?;

let (project, package) = {
let mut splitter = release.links.web_path.splitn(2, "/-/packages/");
match (splitter.next(), splitter.next()) {
Expand Down

0 comments on commit c5293fc

Please sign in to comment.