Skip to content
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

Start server on arbitrary free port or uds address #374

Open
hqdncw opened this issue Sep 6, 2024 · 0 comments
Open

Start server on arbitrary free port or uds address #374

hqdncw opened this issue Sep 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@hqdncw
Copy link

hqdncw commented Sep 6, 2024

What is the problem your feature solves, or the need it fulfills?

I'd like the capability to launch a Pingora server on a random available port or UDS address and get back the port or address chosen.

Describe the solution you'd like

We can take inspiration from Tonic's implementation, which allows us to provide the listener after binding.

let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();

println!(listener.local_addr().unwrap().port());  // prints some random port assigned by the OS

tonic::transport::Server::builder()
    .add_service(svc)
    .serve_with_incoming(tokio_stream::wrappers::TcpListenerStream::new(listener))
    .await
    .unwrap();

Describe alternatives you've considered

...

Additional context

I need to launch multiple Pingora servers simultaneously for integration testing, each on a unique, dynamically assigned port or UDS address, to prevent port/address collisions.

@drcaramelsyrup drcaramelsyrup added the enhancement New feature or request label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants