Skip to content

Commit

Permalink
feat: add uds support for ketama && load-balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangHanDong committed Mar 17, 2024
1 parent a0c25e4 commit 18bf1f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
10 changes: 3 additions & 7 deletions pingora-core/src/protocols/l4/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,9 @@ impl std::str::FromStr for SocketAddr {
fn from_str(s: &str) -> Result<Self, Self::Err> {
if s.starts_with("unix:") {
let path = s.trim_start_matches("unix:");
if path.is_empty() {
panic!("empty UDS path");
} else {
let uds_socket = StdUnixSockAddr::from_pathname(path)
.or_err(crate::BindError, "invalid UDS path")?;
Ok(SocketAddr::Unix(uds_socket))
}
let uds_socket = StdUnixSockAddr::from_pathname(path)
.or_err(crate::BindError, "invalid UDS path")?;
Ok(SocketAddr::Unix(uds_socket))
} else {
match StdSockAddr::from_str(s) {
Ok(addr) => Ok(SocketAddr::Inet(addr)),
Expand Down
6 changes: 0 additions & 6 deletions pingora-ketama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ mod tests {
assert!("/tmp/sock".parse::<SocketAddr>().is_ok());
}

#[test]
#[should_panic]
fn test_uds_panic() {
let _ = "unix:".parse::<SocketAddr>();
}

#[test]
fn matches_nginx_sample() {
let upstream_hosts = ["127.0.0.1:7777", "127.0.0.1:7778"];
Expand Down

0 comments on commit 18bf1f6

Please sign in to comment.