aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorv1xingyue <[email protected]>2024-07-31 01:52:39 +0000
committerAndrew Hauck <[email protected]>2024-08-09 14:30:49 -0700
commit35810d6c923eca12c516bc119e982737e30f824c (patch)
tree2909e95ac2190f7c7e5c95f1c3bbf0153446d973
parent76c4fdacbb0f68dde7b7a60a9e38ef50ee51510b (diff)
downloadpingora-35810d6c923eca12c516bc119e982737e30f824c.tar.gz
pingora-35810d6c923eca12c516bc119e982737e30f824c.zip
add new_with_weight
--- use weight as param --- fix format and doc comment --- add ext as Extensions::new --- Merge branch 'main' into ~~~ Includes-commit: 0d4a658cf83e4c1c6ab90ab79bbc147035357bc6 Includes-commit: 1ee9b327b499328850d2b88d774dfc4241b19015 Includes-commit: 5b05294e244b191c2505928474344f6004469768 Includes-commit: cf8faea7d08513acd11ba3c53dbfe0528c6b7621 Includes-commit: f0cefff7eb3ba2bdc73fc3e7655bb9a8bbdd22cb Replicated-from: https://github.com/cloudflare/pingora/pull/333
-rw-r--r--.bleep2
-rw-r--r--pingora-load-balancing/src/lib.rs8
2 files changed, 8 insertions, 2 deletions
diff --git a/.bleep b/.bleep
index 87e4334..1198c86 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-c02dc12f1f7caf9aa90a13112321cf5c3d2f6b6d \ No newline at end of file
+f6e596e897d73c69369ae85edf58cec64b106969 \ No newline at end of file
diff --git a/pingora-load-balancing/src/lib.rs b/pingora-load-balancing/src/lib.rs
index c5adea3..4009dc1 100644
--- a/pingora-load-balancing/src/lib.rs
+++ b/pingora-load-balancing/src/lib.rs
@@ -77,12 +77,18 @@ 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> {
+ Self::new_with_weight(addr, 1)
+ }
+
+ /// 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<Self> {
let addr = addr
.parse()
.or_err(ErrorType::InternalError, "invalid socket addr")?;
Ok(Backend {
addr: SocketAddr::Inet(addr),
- weight: 1,
+ weight,
ext: Extensions::new(),
})
// TODO: UDS