1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Shared HTTP client construction for the registry clients.
//!
//! Every ecosystem registry (npm, crates.io, `PyPI`, GitHub) builds a
//! `reqwest::Client` with the same timeout and user-agent. Centralising the
//! builder here keeps that configuration in one place; the concurrency ceiling
//! is exposed as a constant because each registry wraps the client in its own
//! [`tokio::sync::Semaphore`].
use Duration;
use Client;
/// Default ceiling on concurrent in-flight registry requests.
///
/// GitHub's registry uses a lower limit (its unauthenticated rate budget is
/// only 60 req/hr); it defines its own constant rather than using this one.
pub const DEFAULT_MAX_CONCURRENT_REQUESTS: usize = 10;
/// Default per-request timeout, in seconds.
pub const DEFAULT_REQUEST_TIMEOUT_SECS: u64 = 30;
/// Build the shared `reqwest::Client` used by every registry.
///
/// Applies the default timeout and a `dependency-check-updates/<version>`
/// user-agent.
///
/// # Panics
///
/// Panics if the client cannot be built. With the fixed configuration used
/// here this never happens in practice — a failure would indicate a broken
/// TLS backend at the platform level, not a recoverable runtime condition.