We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
time.rs•617 B
use std::time::Duration;
/// Returns a [`Duration`] with a small amount of randomness which is not greater than the given Duration.
///
// Note: Jitter implementation thanks to the `fure` crate, released under the MIT license.
//
// See: https://github.com/Leonqn/fure/blob/8945c35655f7e0f6966d8314ab21a297181cc080/src/backoff.rs#L44-L51
pub fn jitter_duration(duration: Duration) -> Duration {
let jitter = rand::random::<f64>();
let secs = ((duration.as_secs() as f64) * jitter).ceil() as u64;
let nanos = ((f64::from(duration.subsec_nanos())) * jitter).ceil() as u32;
Duration::new(secs, nanos)
}