From 5b05294e244b191c2505928474344f6004469768 Mon Sep 17 00:00:00 2001 From: v1xingyue Date: Thu, 18 Jul 2024 12:07:27 +0800 Subject: [PATCH 1/4] add new_with_weight --- pingora-load-balancing/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pingora-load-balancing/src/lib.rs b/pingora-load-balancing/src/lib.rs index c950c85c..11ef27f7 100644 --- a/pingora-load-balancing/src/lib.rs +++ b/pingora-load-balancing/src/lib.rs @@ -58,12 +58,17 @@ impl Backend { /// Create a new [Backend] with `weight` 1. The function will try to parse /// `addr` into a [std::net::SocketAddr]. pub fn new(addr: &str) -> Result { + Self::new_with_weight(addr,1) + } + + // Create a new [Background] with address and weight. + pub fn new_with_weight(addr: &str,weight: usize) -> Result { let addr = addr .parse() .or_err(ErrorType::InternalError, "invalid socket addr")?; Ok(Backend { addr: SocketAddr::Inet(addr), - weight: 1, + weight: weight, }) // TODO: UDS } From f0cefff7eb3ba2bdc73fc3e7655bb9a8bbdd22cb Mon Sep 17 00:00:00 2001 From: v1xingyue Date: Thu, 18 Jul 2024 13:19:22 +0800 Subject: [PATCH 2/4] use weight as param --- pingora-load-balancing/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pingora-load-balancing/src/lib.rs b/pingora-load-balancing/src/lib.rs index 11ef27f7..bdbaf779 100644 --- a/pingora-load-balancing/src/lib.rs +++ b/pingora-load-balancing/src/lib.rs @@ -68,7 +68,7 @@ impl Backend { .or_err(ErrorType::InternalError, "invalid socket addr")?; Ok(Backend { addr: SocketAddr::Inet(addr), - weight: weight, + weight, }) // TODO: UDS } From 0d4a658cf83e4c1c6ab90ab79bbc147035357bc6 Mon Sep 17 00:00:00 2001 From: v1xingyue Date: Mon, 29 Jul 2024 00:34:17 +0800 Subject: [PATCH 3/4] fix format and doc comment --- pingora-load-balancing/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pingora-load-balancing/src/lib.rs b/pingora-load-balancing/src/lib.rs index bdbaf779..6a24c227 100644 --- a/pingora-load-balancing/src/lib.rs +++ b/pingora-load-balancing/src/lib.rs @@ -58,11 +58,12 @@ impl Backend { /// Create a new [Backend] with `weight` 1. The function will try to parse /// `addr` into a [std::net::SocketAddr]. pub fn new(addr: &str) -> Result { - Self::new_with_weight(addr,1) + Self::new_with_weight(addr, 1) } - // Create a new [Background] with address and weight. - pub fn new_with_weight(addr: &str,weight: usize) -> Result { + /// Creates a new [Backend] with the specified `weight`. The function will try to parse + /// `addr` into a [std::net::SocketAddr]. + pub fn new_with_weight(addr: &str, weight: usize) -> Result { let addr = addr .parse() .or_err(ErrorType::InternalError, "invalid socket addr")?; From cf8faea7d08513acd11ba3c53dbfe0528c6b7621 Mon Sep 17 00:00:00 2001 From: v1xingyue Date: Wed, 31 Jul 2024 09:41:38 +0800 Subject: [PATCH 4/4] add ext as Extensions::new --- pingora-load-balancing/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pingora-load-balancing/src/lib.rs b/pingora-load-balancing/src/lib.rs index 6a24c227..4922c465 100644 --- a/pingora-load-balancing/src/lib.rs +++ b/pingora-load-balancing/src/lib.rs @@ -70,6 +70,7 @@ impl Backend { Ok(Backend { addr: SocketAddr::Inet(addr), weight, + ext: Extensions::new(), }) // TODO: UDS }