diff options
author | Alex Auvolat <alex@adnab.me> | 2021-12-07 16:37:22 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-12-07 16:37:22 +0100 |
commit | ccb4e87658f622edbd57cc2b5a058c969643bfe2 (patch) | |
tree | a958a0221062a21e7db3859e7b6843d7e5bd8b7c /src/proxy_config.rs | |
parent | cd7e5ad034b75d659d4d87a752ab7b11cf75de12 (diff) | |
download | tricot-ccb4e87658f622edbd57cc2b5a058c969643bfe2.tar.gz tricot-ccb4e87658f622edbd57cc2b5a058c969643bfe2.zip |
Round robin backends
Diffstat (limited to 'src/proxy_config.rs')
-rw-r--r-- | src/proxy_config.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs index 891fdef..8c2444a 100644 --- a/src/proxy_config.rs +++ b/src/proxy_config.rs @@ -1,5 +1,5 @@ use std::net::SocketAddr; -use std::sync::Arc; +use std::sync::{atomic, Arc}; use std::{cmp, time::Duration}; use log::*; @@ -12,9 +12,15 @@ use crate::consul::*; #[derive(Debug)] pub struct ProxyEntry { pub target_addr: SocketAddr, + pub host: String, pub path_prefix: Option<String>, pub priority: u32, + + // 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, } #[derive(Debug)] @@ -53,6 +59,7 @@ fn parse_tricot_tag(target_addr: SocketAddr, tag: &str) -> Option<ProxyEntry> { host: host.to_string(), path_prefix, priority, + calls: atomic::AtomicU64::from(0), }) } |