Skip to content

Commit

Permalink
add new_with_weight
Browse files Browse the repository at this point in the history
---
use weight as param
---
fix format and doc comment
---
add ext as Extensions::new
---
Merge branch 'main' into ~~~

Includes-commit: 0d4a658
Includes-commit: 1ee9b32
Includes-commit: 5b05294
Includes-commit: cf8faea
Includes-commit: f0cefff
Replicated-from: #333
  • Loading branch information
v1xingyue authored and andrewhavck committed Aug 9, 2024
1 parent 76c4fda commit 35810d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c02dc12f1f7caf9aa90a13112321cf5c3d2f6b6d
f6e596e897d73c69369ae85edf58cec64b106969
8 changes: 7 additions & 1 deletion pingora-load-balancing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 35810d6

Please sign in to comment.