Skip to content

Commit

Permalink
expose new_uds err
Browse files Browse the repository at this point in the history
  • Loading branch information
cospectrum committed Apr 21, 2024
1 parent 845c30d commit 7345c17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pingora-core/src/upstreams/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ impl HttpPeer {
}

/// Create a new [`HttpPeer`] with the given path to Unix domain socket and TLS settings.
pub fn new_uds(path: &str, tls: bool, sni: String) -> Self {
let addr = SocketAddr::Unix(UnixSocketAddr::from_pathname(Path::new(path)).unwrap()); //TODO: handle error
Self::new_from_sockaddr(addr, tls, sni)
pub fn new_uds(path: &str, tls: bool, sni: String) -> std::io::Result<Self> {
let addr = SocketAddr::Unix(UnixSocketAddr::from_pathname(Path::new(path))?);
Ok(Self::new_from_sockaddr(addr, tls, sni))
}

/// Create a new [`HttpPeer`] that uses a proxy to connect to the upstream IP and port
Expand Down
8 changes: 3 additions & 5 deletions pingora-proxy/tests/utils/server_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,9 @@ impl ProxyHttp for ExampleProxyHttp {
) -> Result<Box<HttpPeer>> {
let req = session.req_header();
if req.headers.contains_key("x-uds-peer") {
return Ok(Box::new(HttpPeer::new_uds(
"/tmp/nginx-test.sock",
false,
"".to_string(),
)));
return Ok(Box::new(
HttpPeer::new_uds("/tmp/nginx-test.sock", false, "".to_string()).unwrap(),
));
}
let port = req
.headers
Expand Down

0 comments on commit 7345c17

Please sign in to comment.