use socket2::SockRef;
use tokio::net::TcpStream;
use vector_config::configurable_component;
#[configurable_component]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
#[configurable(metadata(docs::human_name = "Wait Time"))]
pub struct TcpKeepaliveConfig {
#[configurable(metadata(docs::type_unit = "seconds"))]
pub time_secs: Option<u64>,
}
pub(crate) fn set_keepalive(
socket: &TcpStream,
params: &socket2::TcpKeepalive,
) -> std::io::Result<()> {
SockRef::from(socket).set_tcp_keepalive(params)
}
pub(crate) fn set_receive_buffer_size(socket: &TcpStream, size: usize) -> std::io::Result<()> {
SockRef::from(socket).set_recv_buffer_size(size)
}
pub(crate) fn set_send_buffer_size(socket: &TcpStream, size: usize) -> std::io::Result<()> {
SockRef::from(socket).set_send_buffer_size(size)
}