mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-20 02:31:35 +02:00
add new_with_weight
--- use weight as param --- fix format and doc comment --- add ext as Extensions::new --- Merge branch 'main' into ~~~ Includes-commit:0d4a658cf8
Includes-commit:1ee9b327b4
Includes-commit:5b05294e24
Includes-commit:cf8faea7d0
Includes-commit:f0cefff7eb
Replicated-from: https://github.com/cloudflare/pingora/pull/333
This commit is contained in:
parent
76c4fdacbb
commit
35810d6c92
2 changed files with 8 additions and 2 deletions
2
.bleep
2
.bleep
|
@ -1 +1 @@
|
||||||
c02dc12f1f7caf9aa90a13112321cf5c3d2f6b6d
|
f6e596e897d73c69369ae85edf58cec64b106969
|
|
@ -77,12 +77,18 @@ 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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
|
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,
|
||||||
ext: Extensions::new(),
|
ext: Extensions::new(),
|
||||||
})
|
})
|
||||||
// TODO: UDS
|
// TODO: UDS
|
||||||
|
|
Loading…
Reference in a new issue