Skip to content

Conversation

apognu
Copy link

@apognu apognu commented Mar 3, 2025

This PR adds the ability to instruct Postgres to listen on UNIX sockets instead of on a TCP port.

It adds a WithoutTcp() method to the configuration to make the switch. By default, it follows Postgres's default to creating the socket in /tmp, but the socket path can be customized through WithUnixSocketDirectory(dir string).

It modifies the config's GetConnectionURL() to take the current mode of connection into account, and adds a public GetConnectionURL() method on EmbeddedPostgres to proxy it (I would have preferred for those to return *url.URLs, but did not want to change the signature of public methods.

@fergusstrange
Copy link
Owner

Hi,

Apologies for the delay here. I think this would be a valuable addition but ideally it would be good to minimise extra config. Would it be possible to switch the logic around so that there is only one config option of WithUnixSocket which if present turns on the configuration & sets the value? We can set the default behaviour in the setter there if needed.

You'll also need to retain all the existing test coverage and ensure coverage is added to remain at the same level as I notice one test was deleted.

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