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

Add support for connecting to a Postgres database via Unix sockets. #70

Merged
merged 5 commits into from May 31, 2018

Conversation

3 participants
@MrMage
Copy link
Contributor

MrMage commented May 27, 2018

Happy to add a connectivity test as well, but I don't know whether the Postgres DB used in CI is set up for supporting Unix sockets. Let me know if you can provide any insights on that.

Motivation: Unix sockets have lower latency and higher throughput than TCP sockets. There are reports that indicate this to be particularly relevant when using Google Cloud SQL proxy.

@tanner0101
Copy link
Member

tanner0101 left a comment

Looks great, just some gardening comments 👍

extension PostgreSQLConnection {
/// Connects to a Redis server using a TCP socket.
public static func connect(
hostname: String = "localhost",

This comment has been minimized.

@tanner0101

tanner0101 May 30, 2018

Member

There needs to be a deprecated method for this old API

This comment has been minimized.

@MrMage

MrMage May 30, 2018

Author Contributor

Added one.

extension PostgreSQLConnection {
/// Connects to a PostgreSQL server using a TCP socket.
public static func connect(
to serverAddress: PostgreSQLDatabaseConfig.ServerAddress = .default,

This comment has been minimized.

@tanner0101

tanner0101 May 30, 2018

Member

There appears to be a formatting issue here.

This comment has been minimized.

@MrMage

MrMage May 30, 2018

Author Contributor

Done, thanks! Fixed whitespace everywhere.

case unixSocket(path: String)

public static let `default` = ServerAddress.tcp(hostname: "localhost", port: 5432)
public static let defaultViaSocket = ServerAddress.unixSocket(path: "/tmp/.s.PGSQL.5432")

This comment has been minimized.

@tanner0101

tanner0101 May 30, 2018

Member

I think socketDefault would be a fine name here.

This comment has been minimized.

@MrMage

MrMage May 30, 2018

Author Contributor

Renamed.

/// Destination port.
public let port: Int

public enum ServerAddress {

This comment has been minimized.

@tanner0101

tanner0101 May 30, 2018

Member

This deserves a comment.

This comment has been minimized.

@MrMage

MrMage May 30, 2018

Author Contributor

Added.

@tanner0101 tanner0101 added this to the 1.0.0 milestone May 30, 2018

@tanner0101 tanner0101 self-assigned this May 30, 2018

@MrMage

This comment has been minimized.

Copy link
Contributor Author

MrMage commented May 30, 2018

PTAL

MrMage added some commits May 30, 2018

@tanner0101
Copy link
Member

tanner0101 left a comment

great, thanks!

@tanner0101 tanner0101 merged commit 07fe6bd into master May 31, 2018

3 checks passed

ci/circleci: linux Your tests passed on CircleCI!
Details
ci/circleci: linux-fluent Your tests passed on CircleCI!
Details
ci/circleci: linux-release Your tests passed on CircleCI!
Details
@penny-coin

This comment has been minimized.

Copy link

penny-coin commented May 31, 2018

Hey @MrMage, you just merged a pull request, have a coin!

You now have 9 coins.

@tanner0101 tanner0101 deleted the unix-sockets branch May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment