-
-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(rust)::> used portpicker crate to avoid port clash in ockam examples #8304
chore(rust)::> used portpicker crate to avoid port clash in ockam examples #8304
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update the commit message to chore(rust): used portpicker crate to avoid port clash in ockam examples
0ee2a6d
to
fc60a2e
Compare
Hi @metaclips |
Hi @adrianbenavides |
Hi @adrianbenavides pub enum Error {
......
#[error("failed to bind with given address")]
BindError(#[source] io::Error),
#[error("failed to get local socket address of the listener")]
AddrError(#[source] io::Error),
}
pub fn find_available_port() -> Result<u16> {
let listener = TcpListener::bind("127.0.0.1:0").map_err(Error::BindError)?;
let address = listener.local_addr().map_err(Error::AddrError)?;
Ok(address.port())
} |
It's not necessary in this case. Generally, you don't want to map every possible error into an enum variant, just the ones you want to act upon. In this case, we just want to convert external error types into our own and print them. |
Thanks @PsychoPunkSage for this PR 🙏 It looks good, but you'll also have to sign your commits here before I can approve it. https://docs.github.com/en/authentication/managing-commit-signature-verification |
Hi @adrianbenavides |
7452a01
to
d6ad83e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to merge, thanks a lot @PsychoPunkSage for your PR!! 🙏
Current behavior
Some tests in
examples/rust/*
could clash on TCP ports when run in parallel.Proposed changes
Use
portpicker
crate to avoid port clash. Now tests will ask the OS for free ports, rather then using hardcoded values.This PR addresses #3005 pointer 2