Skip to content

Support keepalive interval and retries. #944

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

Merged

Conversation

PG-kura
Copy link

@PG-kura PG-kura commented Aug 26, 2022

hello. I use tokio-postgres a lot.

Thing I want to do

I would like to customize interval and retries when keepalive is turned on.
Therefore, I propose to make it possible to specify the keepalive interval and retries in this pull-request.

Features to add

Previously, the only keepalive parameter was keepalives_idle. This time, add keepalives_interval and keepalives_retries. keepalives_interval is available on neither Redox nor Solaris. keepalives_retries is available on neither Redox, Solaris nor Windows. This constraint aligns with that of socket2::TcpKeepalive.

Implementation

I thought that adding keepalives_interval and keepalives_retries blindly would increase the number of arguments for the connect_socket::connect_socket() and make the source code messy.
So I defined a new struct KeepaliveConfig. It does not publish outside the crate.
As an alternative, I considered putting socket2::TcpKeepalive in Config, but I rejected it because socket2::TcpKeepalive has no getter method and is incompatible with Config.

@sfackler
Copy link
Owner

Looks good to me other than the one comment!

@sfackler sfackler merged commit 14e11bd into sfackler:master Aug 27, 2022
@sfackler
Copy link
Owner

Thanks!

@PG-kura PG-kura deleted the support-keepalive-interval-and-retries branch August 27, 2022 16:23
@PG-kura PG-kura restored the support-keepalive-interval-and-retries branch October 13, 2022 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants