mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 04:30:03 +00:00
binstalk-registry
: Rm rate-limit for crates.io registry (#1299)
Fixed #1295 The 1 request per second rate-limit is too strict and it makes `cargo-binstall` very slow when resolving many crates in parallel. Relying on the rate-limit in `binstalk_downloader::remote::Client` should be good enough. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
2215682e76
commit
f0f0c2bd14
3 changed files with 6 additions and 49 deletions
|
@ -34,7 +34,7 @@ mod git_registry;
|
|||
pub use git_registry::GitRegistry;
|
||||
|
||||
mod crates_io_registry;
|
||||
pub use crates_io_registry::{fetch_crate_cratesio, CratesIoRateLimit};
|
||||
pub use crates_io_registry::fetch_crate_cratesio;
|
||||
|
||||
mod sparse_registry;
|
||||
pub use sparse_registry::SparseRegistry;
|
||||
|
@ -100,10 +100,11 @@ impl From<CargoTomlError> for RegistryError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[non_exhaustive]
|
||||
pub enum Registry {
|
||||
CratesIo(Arc<CratesIoRateLimit>),
|
||||
#[default]
|
||||
CratesIo,
|
||||
|
||||
Sparse(Arc<SparseRegistry>),
|
||||
|
||||
|
@ -111,12 +112,6 @@ pub enum Registry {
|
|||
Git(GitRegistry),
|
||||
}
|
||||
|
||||
impl Default for Registry {
|
||||
fn default() -> Self {
|
||||
Self::CratesIo(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, ThisError)]
|
||||
#[error("Invalid registry `{src}`, {inner}")]
|
||||
pub struct InvalidRegistryError {
|
||||
|
@ -175,9 +170,7 @@ impl Registry {
|
|||
version_req: &VersionReq,
|
||||
) -> Result<Manifest<Meta>, RegistryError> {
|
||||
match self {
|
||||
Self::CratesIo(rate_limit) => {
|
||||
fetch_crate_cratesio(client, crate_name, version_req, rate_limit).await
|
||||
}
|
||||
Self::CratesIo => fetch_crate_cratesio(client, crate_name, version_req).await,
|
||||
Self::Sparse(sparse_registry) => {
|
||||
sparse_registry
|
||||
.fetch_crate_matched(client, crate_name, version_req)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue