Skip to content

Commit

Permalink
add new_with_weight
Browse files Browse the repository at this point in the history
  • Loading branch information
v1xingyue authored Jul 18, 2024
1 parent 42a847d commit 5b05294
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pingora-load-balancing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Self::new_with_weight(addr,1)
}

// Create a new [Background] with address and weight.
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: weight,
})
// TODO: UDS
}
Expand Down

0 comments on commit 5b05294

Please sign in to comment.