cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
20.25k stars 1.1k forks source link

Set tcp keepalive to l4 listener accept stream #241

Closed vicanso closed 1 month ago

vicanso commented 1 month ago

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

I want to set tcp keepalive for l4 listener accept stream, but pingora only supports set to l4 connector.

Describe the solution you'd like

Support to set tcp keepalive for tcp accept function.

Self::Tcp(l) => l.accept().await.map(|(stream, peer_addr)| {
                let _ = set_tcp_keepalive(
                    &stream,
                    &TcpKeepalive {
                        idle: std::time::Duration::from_secs(5 * 60),
                        interval: std::time::Duration::from_secs(60),
                        count: 1000,
                    },
                );

Describe alternatives you've considered

What other solutions, features, or workarounds have you considered that might also solve the issue? What are the tradeoffs for these alternatives compared to what you're proposing?

Additional context

This could include references to documentation or papers, prior art, screenshots, or benchmark results.

drcaramelsyrup commented 1 month ago

Thanks, added in 6db86b692945a7b1eee12f288366f26794d810b6 as part of TcpSocketOptions. Let us know if that doesn't meet your needs.