Skip to content

Commit

Permalink
Minor doc/typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xnuter committed May 30, 2021
1 parent fb4a144 commit ffd5cd2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/proxy_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ pub struct Nugget {

type CachedSocketAddrs = (Vec<SocketAddr>, u128);

/// Caching DNS resolution results to minimize DNS lookups.
/// The cache implementation is relaxed, it allows concurrent lookups of the same key,
/// Caching DNS resolution to minimize DNS look-ups.
/// The cache has relaxed consistency, it allows concurrent DNS look-ups of the same key,
/// without any guarantees which result is going to be cached.
///
/// Given it's used for DNS lookups this trade-off seems to be reasonable.
/// Given it's used for DNS look-ups this trade-off seems to be reasonable.
#[derive(Clone)]
pub struct SimpleCachingDnsResolver {
// mostly reads, occasional writes
Expand Down Expand Up @@ -151,9 +151,9 @@ impl SimpleCachingDnsResolver {
let addr = match map.get(target) {
None => None,
Some((cached, expiration)) => {
// expiration with gitter to avoid waves of expirations
let expiration_gitter = *expiration + thread_rng().gen_range(0..5_000);
if Instant::now().duration_since(self.start_time).as_millis() < expiration_gitter {
// expiration with jitter to avoid expiration "waves"
let expiration_jitter = *expiration + thread_rng().gen_range(0..5_000);
if Instant::now().duration_since(self.start_time).as_millis() < expiration_jitter {
Some(self.pick(cached))
} else {
None
Expand Down

0 comments on commit ffd5cd2

Please sign in to comment.