Skip to content

Add support for UDS and existing Channels #335

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
merged 13 commits into from
Apr 20, 2023

Conversation

gwynne
Copy link
Member

@gwynne gwynne commented Apr 13, 2023

Extends PostgresConnection to enable connecting to Postgres servers over UNIX domain sockets or using a preexisting Channel.

In the process, most of the existing structure of PostgresConnection.Configuration has been deprecated in favor of new APIs with more options and cleaner design. The deprecation messages provide instructions on migrating existing code. List of deprecations and their replacements (all listed APIs should be assumed to have a PostgresConnection. prefix):

  • Configuration.Connection and .connection -> Configuration.host, .port, .unixDomainSocket, and .establishedChannel properties, and respective initializers.
  • Configuration.Authentication and .authentication -> Configuration.username, .password, and .database properties.
  • New Configuration.Options structure and .options property, containing the connectTimeout and requireBackendKeyData properties previously found on Configuration.Connection.

Note: The integration tests for UNIX domain sockets will be skipped unless POSTGRES_SOCKET is set to a socket path in the test environment. See the updated test.yml for examples of how to do so correctly.

Closes #259
Closes #268

@gwynne gwynne added the enhancement New feature or request label Apr 13, 2023
@gwynne gwynne requested review from fabianfett, 0xTim and MahdiBM April 13, 2023 11:37
@gwynne gwynne self-assigned this Apr 13, 2023
@gwynne
Copy link
Member Author

gwynne commented Apr 13, 2023

/cc @MahdiBM @tkrajacic

@gwynne
Copy link
Member Author

gwynne commented Apr 13, 2023

This PR is intended to subsume both #302 and #314, lmk if there's anything missing.

@0xTim
Copy link
Member

0xTim commented Apr 13, 2023

Resolves #259

@0xTim 0xTim linked an issue Apr 13, 2023 that may be closed by this pull request
@gwynne
Copy link
Member Author

gwynne commented Apr 13, 2023

CI failure on nightly-main is tracked by swiftlang/swift#65064

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - only thing to mention that I couldn't quite tell is that it looks like all the tests have been updated to use the new APIs. We should probably have a test just to ensure the deprecated stuff still works

@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2023

Codecov Report

Merging #335 (e8ad7df) into main (c996d62) will decrease coverage by 0.23%.
The diff coverage is 32.16%.

❗ Current head e8ad7df differs from pull request most recent head f8ae7a2. Consider uploading reports for the commit f8ae7a2 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
- Coverage   41.27%   41.04%   -0.23%     
==========================================
  Files         115      117       +2     
  Lines        9572     9657      +85     
==========================================
+ Hits         3951     3964      +13     
- Misses       5621     5693      +72     
Impacted Files Coverage Δ
.../PostgresConnection+Configuration+Deprecated.swift 0.00% <0.00%> (ø)
...es/PostgresNIO/New/Data/UUID+PostgresCodable.swift 96.96% <ø> (ø)
Sources/PostgresNIO/New/PostgresCodable.swift 93.87% <ø> (ø)
...es/PostgresNIO/Connection/PostgresConnection.swift 12.03% <22.22%> (-4.60%) ⬇️
.../Connection/PostgresConnection+Configuration.swift 44.44% <44.44%> (ø)
...urces/PostgresNIO/New/PostgresChannelHandler.swift 62.06% <100.00%> (+0.92%) ⬆️

Copy link
Collaborator

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks way better.

@gwynne gwynne requested a review from fabianfett April 19, 2023 18:00
@gwynne gwynne force-pushed the add-uds-and-channel-connection branch from 6eca626 to 7f950f6 Compare April 19, 2023 18:01
Copy link
Collaborator

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOVELY! Nits

gwynne added 8 commits April 20, 2023 06:20
…able (falls back to the BUILDING_DOCC flag for older versions)
…rty, ditch pointless use of @_implementationOnly, use internal backing store rather than public API for internal access to config info, revert unnecessary changes to tests
@gwynne gwynne force-pushed the add-uds-and-channel-connection branch from 7f950f6 to e8ad7df Compare April 20, 2023 11:23
@gwynne gwynne requested a review from fabianfett April 20, 2023 11:23
@gwynne gwynne force-pushed the add-uds-and-channel-connection branch 2 times, most recently from 28b511f to f8ae7a2 Compare April 20, 2023 11:37
@gwynne gwynne force-pushed the add-uds-and-channel-connection branch from f8ae7a2 to d6edb3a Compare April 20, 2023 11:39
Copy link
Collaborator

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The new connect syntax appears to be missing an option for unix domain sockets Support establishing connections over existing NIO channels
5 participants