Skip to content

Commit

Permalink
refactor: choose a random server for blob downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
crepererum committed Dec 8, 2024
1 parent d0cf4a0 commit 6dbc4ff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/blob.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::{bail, Context, Result};
use rand::{seq::IteratorRandom, thread_rng};
use reqwest::Method;

use crate::{
Expand Down Expand Up @@ -163,7 +164,12 @@ async fn get_access(
.await
.context("blob service access request")?;

let Some(server) = resp.blob_access_info.servers.first() else {
let Some(server) = resp
.blob_access_info
.servers
.into_iter()
.choose(&mut thread_rng())
else {
bail!("no blob servers provided")
};

Expand Down

0 comments on commit 6dbc4ff

Please sign in to comment.