mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-20 02:31:35 +02:00
add new_with_weight
This commit is contained in:
parent
42a847d372
commit
5b05294e24
1 changed files with 6 additions and 1 deletions
|
@ -58,12 +58,17 @@ impl Backend {
|
||||||
/// Create a new [Backend] with `weight` 1. The function will try to parse
|
/// Create a new [Backend] with `weight` 1. The function will try to parse
|
||||||
/// `addr` into a [std::net::SocketAddr].
|
/// `addr` into a [std::net::SocketAddr].
|
||||||
pub fn new(addr: &str) -> Result<Self> {
|
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
|
let addr = addr
|
||||||
.parse()
|
.parse()
|
||||||
.or_err(ErrorType::InternalError, "invalid socket addr")?;
|
.or_err(ErrorType::InternalError, "invalid socket addr")?;
|
||||||
Ok(Backend {
|
Ok(Backend {
|
||||||
addr: SocketAddr::Inet(addr),
|
addr: SocketAddr::Inet(addr),
|
||||||
weight: 1,
|
weight: weight,
|
||||||
})
|
})
|
||||||
// TODO: UDS
|
// TODO: UDS
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue