[deps] remove glob, hex, and humantime dependencies
1240 unmodified linesExpand all1241124212431244124512461247124812491250124512461247124879 unmodified lines13281329133013311338133913401341134213431332133313341335116 unmodified linesExpand all145214531454145514681469147014711472147314561457145814591460146114621463146414651466146714681469148714881470147114911472147314741475147614772898 unmodified linesExpand all1240 unmodified linesExpand allsource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
[[package]]name = "glob"version = "0.3.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
[[package]]name = "group"version = "0.13.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"79 unmodified lines "stable_deref_trait",]
[[package]]name = "hex"version = "0.4.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]name = "hickory-net"version = "0.26.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "084e7bd6a377435d568f652153e571b50970d7ccc1d1eeec0519f834632287e1"116 unmodified linesExpand allsource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]name = "humantime"version = "2.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
[[package]]name = "hydrant"version = "0.1.0"dependencies = [ "ahash", "arc-swap", "aws-lc-rs", "axum", "bytes", "chrono", "cid", "criterion", "data-encoding", "fjall", "futures", "glob", "hex", "hickory-resolver", "http", "humantime", "hyper", "hyper-util", "ipnet", "jacquard-common", "k256", "libc",2898 unmodified linesExpand all53 unmodified lines5455565758585960616362636465666967686970717273747576777879808137 unmodified lines53 unmodified lines
jacquard-common = { git = "https://tangled.org/nonbinary.computer/jacquard", rev = "9046f2822f4685217300c4a03551b4484fcbc31d", default-features = false, features = ["std", "crypto"] }hickory-resolver = { version = "0.26.2", features = ["system-config", "tokio"], default-features = false }chrono = { version = "0.4.43", features = ["serde"] }humantime = "2.3.0"
mimalloc = { version = "0.1", features = ["v3"], optional = true }tikv-jemallocator = { version = "0.6", optional = true }snmalloc-rs = { version = "0.3", optional = true }hex = "0.4"scc = "3.6.6"data-encoding = "2.10.0"cid = "0.11.1"thiserror = "2.0.18"rand = "0.10.0"glob = "0.3"arc-swap = "1.8.2"rustls = { version = "0.23", features = ["aws-lc-rs"] }tokio-websockets = { version = "0.13.2", default-features = false, features = ["client", "server", "rustls-native-roots", "aws_lc_rs", "rand"] }multibase = "0.9.2"# asm gates the armv8 sha2 instructions; without it aarch64 hashes in softwaresha2 = { version = "0.10.9", features = ["asm"] }parking_lot = { version = "0.12.5", features = ["arc_lock"] }hyper = "1.8.1"hyper-util = { version = "0.1", features = ["tokio"] }http = "1"aws-lc-rs = { version = "1", default-features = false }ahash = "0.8.12"# statvfs for the free-disk check before a backfill spills, already in the tree through tokiolibc = "0.2"k256 = { version = "0.13", features = ["ecdsa"] }37 unmodified lines769 unmodified linesExpand all770771772773774774775776777778117 unmodified linesExpand all769 unmodified linesExpand all ) )?; config_line!(f, "ephemeral", self.ephemeral)?; if let Some(ttl) = self.history_ttl { config_line!(f, "history ttl", humantime::format_duration(ttl))?; config_line!(f, "history ttl", crate::util::format_duration(ttl))?; } config_line!(f, "database path", self.database_path.to_string_lossy())?; config_line!(f, "cache size", format_args!("{} mb", self.cache_size))?; config_line!(f, "data compression", self.data_compression)?;117 unmodified linesExpand all83 unmodified lines848586878888899091921 unmodified line83 unmodified lines (FilterMode::Filter, "a666696c746572", "\"filter\""), (FilterMode::Full, "a466756c6c", "\"full\""), ] { let encoded = rmp_serde::to_vec(&mode).unwrap(); assert_eq!(hex::encode(&encoded), msgpack); assert_eq!(data_encoding::HEXLOWER.encode(&encoded), msgpack); assert_eq!(rmp_serde::from_slice::<FilterMode>(&encoded).unwrap(), mode); assert_eq!(serde_json::to_string(&mode).unwrap(), json); } }1 unmodified line93 unmodified lines94959697989910010110210310410510610710810911011111211311411511611711811910012012112212312426 unmodified lines15115215315413515515615715815916016116210 unmodified lines17317417517617717817918018120 unmodified lines93 unmodified linespub(crate) fn new_handle(meta: PdsMeta) -> PdsMetaHandle { Arc::new(ArcSwap::new(Arc::new(meta)))}
fn glob_match(pat: &[u8], text: &[u8]) -> bool { let (mut p, mut t, mut star) = (0, 0, None); while t < text.len() { if p < pat.len() && pat[p] == b'*' { star = Some((p + 1, t)); p += 1; } else if p < pat.len() && (pat[p] == b'?' || pat[p] == text[t]) { p += 1; t += 1; } else if let Some((sp, st)) = &mut star { p = *sp; *st += 1; t = *st; } else { return false; } } pat[p..].iter().all(|&b| b == b'*')}
#[derive(Debug, Clone)]pub struct TierRule { pub pattern: glob::Pattern, pub pattern: SmolStr, pub tier_name: SmolStr,}
/// policy for resolving rate tiers for PDS hosts.26 unmodified lines debug!(host, override = %name, account_limit = ?tier.account_limit, "tier resolved via explicit override"); return tier; }
let matched = self.rules.iter().find(|r| r.pattern.matches(host)); let matched = self .rules .iter() .find(|r| glob_match(r.pattern.as_bytes(), host.as_bytes()));
let tier = matched .and_then(|r| self.tiers.get(&r.tier_name).copied()) .unwrap_or(default);10 unmodified lines
#[cfg(test)]mod tests { use super::*; use crate::util::hex;
#[test] fn host_status_persisted_golden_fixtures() { for (status, msgpack, json) in [20 unmodified lines798 unmodified linesExpand all79980080180280380380480580680735 unmodified lines84384484584684784784884985085138 unmodified lines89089189289389489489589689789835 unmodified lines798 unmodified linesExpand all }), ]; let encoded = jobs .iter() .map(|job| hex::encode(rmp_serde::to_vec(job).unwrap())) .map(|job| crate::util::hex::encode(rmp_serde::to_vec(job).unwrap())) .collect::<Vec<_>>(); assert_eq!( encoded, [35 unmodified lines .iter() .map(|state| rmp_serde::to_vec(state).unwrap()) .collect::<Vec<_>>(); assert_eq!( encoded.iter().map(hex::encode).collect::<Vec<_>>(), encoded.iter().map(crate::util::hex::encode).collect::<Vec<_>>(), [ "81a54572726f7293ab526174656c696d6974656407d0d6", "81a54572726f7293a95472616e73706f72740800", "81a54572726f7293a747656e65726963092a",38 unmodified lines relay_inactive: None, backfilled_rev: None, }; let encoded = rmp_serde::to_vec(&metadata).unwrap(); assert_eq!(hex::encode(&encoded), "95c30702c0c0"); assert_eq!(crate::util::hex::encode(&encoded), "95c30702c0c0"); let decoded: RepoMetadata = rmp_serde::from_slice(&encoded).unwrap(); assert!(decoded.tracked); assert_eq!(decoded.index_id, 7); assert_eq!(decoded.retry_count, 2);35 unmodified lines