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:
v1xingyue 2024-07-31 01:52:39 +00:00 committed by Andrew Hauck
parent 76c4fdacbb
commit 35810d6c92
2 changed files with 8 additions and 2 deletions

2
.bleep
View file

@ -1 +1 @@
c02dc12f1f7caf9aa90a13112321cf5c3d2f6b6d
f6e596e897d73c69369ae85edf58cec64b106969

View file

@ -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