diff options
author | Alex Auvolat <alex@adnab.me> | 2021-12-08 22:29:08 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-12-08 22:29:08 +0100 |
commit | 62c745898d35287577caa0bd384cc7bc39f6b4ec (patch) | |
tree | c2730e745f39ff54ad000cb38150b77c385958df | |
parent | 7dbf848de3137158d1e12c2cd547ab4778fcf5a0 (diff) | |
download | tricot-62c745898d35287577caa0bd384cc7bc39f6b4ec.tar.gz tricot-62c745898d35287577caa0bd384cc7bc39f6b4ec.zip |
Inverse how priorities work
-rw-r--r-- | src/https.rs | 9 | ||||
-rw-r--r-- | src/proxy_config.rs | 6 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/https.rs b/src/https.rs index 7d64e44..e1db42e 100644 --- a/src/https.rs +++ b/src/https.rs @@ -100,15 +100,14 @@ async fn handle( .map(|prefix| path.starts_with(prefix)) .unwrap_or(true) }) - .min_by_key(|ent| { + .max_by_key(|ent| { ( ent.priority, - -(ent - .path_prefix + ent.path_prefix .as_ref() .map(|x| x.len() as i32) - .unwrap_or(0)), - ent.calls.load(Ordering::SeqCst), + .unwrap_or(0), + -ent.calls.load(Ordering::SeqCst), ) }); diff --git a/src/proxy_config.rs b/src/proxy_config.rs index 399b52a..8a64f53 100644 --- a/src/proxy_config.rs +++ b/src/proxy_config.rs @@ -50,7 +50,7 @@ pub struct ProxyEntry { // Counts the number of times this proxy server has been called to // This implements a round-robin load balancer if there are multiple // entries for the same host and same path prefix. - pub calls: atomic::AtomicU64, + pub calls: atomic::AtomicI64, } impl std::fmt::Display for ProxyEntry { @@ -69,7 +69,7 @@ impl std::fmt::Display for ProxyEntry { if !self.add_headers.is_empty() { write!(f, " +Headers: {:?}", self.add_headers)?; } - Ok(()) + write!(f, " ({})", self.calls.load(atomic::Ordering::Relaxed)) } } @@ -125,7 +125,7 @@ fn parse_tricot_tag( path_prefix, priority, add_headers: add_headers.to_vec(), - calls: atomic::AtomicU64::from(0), + calls: atomic::AtomicI64::from(0), }) } |