Skip to content
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

Apply updates for improved interop with SQLKit #259

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/contributing.md

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
if: ${{ false && !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container:
image: swift:5.9-jammy
image: swift:5.10-jammy
permissions: { actions: write, contents: read, security-events: write }
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -111,10 +111,9 @@ jobs:
- postgres:14
- postgres:12
swift-image:
- swift:5.7-jammy
- swift:5.8-jammy
- swift:5.9-jammy
- swiftlang/swift:nightly-5.10-jammy
- swift:5.10-jammy
- swiftlang/swift:nightly-main-jammy
include:
- postgres-image: postgres:16
Expand Down Expand Up @@ -143,7 +142,7 @@ jobs:
linux-integration:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.9-jammy
container: swift:5.10-jammy
services:
psql-a:
image: postgres:16
Expand Down Expand Up @@ -194,11 +193,12 @@ jobs:
xcode-version: ${{ matrix.xcode-version }}
- name: Install Postgres, setup DB and auth, and wait for server start
run: |
brew upgrade || true
export PATH="$(brew --prefix)/opt/postgresql@14/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
(brew unlink postgresql || true) && brew install "postgresql@15" && brew link --force "postgresql@15"
(brew unlink postgresql@14 || true) && brew install "postgresql@15" && brew link --force "postgresql@15"
initdb --locale=C --auth-host "scram-sha-256" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
pg_ctl start --wait
timeout-minutes: 2
timeout-minutes: 15
- name: Checkout code
uses: actions/checkout@v4
- name: Run local tests
Expand Down
45 changes: 31 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.8
import PackageDescription

let package = Package(
Expand All @@ -13,21 +13,38 @@ let package = Package(
.library(name: "PostgresKit", targets: ["PostgresKit"]),
],
dependencies: [
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.14.2"),
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.20.2"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.28.0"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.14.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.1.0")
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0")
],
targets: [
.target(name: "PostgresKit", dependencies: [
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "SQLKit", package: "sql-kit"),
.product(name: "Atomics", package: "swift-atomics")
]),
.testTarget(name: "PostgresKitTests", dependencies: [
.target(name: "PostgresKit"),
.product(name: "SQLKitBenchmark", package: "sql-kit"),
]),
.target(
name: "PostgresKit",
dependencies: [
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "SQLKit", package: "sql-kit"),
.product(name: "Atomics", package: "swift-atomics"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "PostgresKitTests",
dependencies: [
.target(name: "PostgresKit"),
.product(name: "SQLKitBenchmark", package: "sql-kit"),
],
swiftSettings: swiftSettings
),
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("StrictConcurrency=complete"),
] }
gwynne marked this conversation as resolved.
Show resolved Hide resolved
49 changes: 0 additions & 49 deletions [email protected]
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually have strict concurrency warnings without this manifest? I'm confused as to why we don't need this anymore, or was it because the flags weren't recognised in 5.7 but are in 5.8?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct - the upcoming/experimental feature flag support was first available in SwiftPM as of 5.8; as of that version being the minimum, we don't need a separate manifest anymore unless we're using 5.9-only manifest features like macros.

This file was deleted.

13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,19 @@
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/postgres-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/postgres-kit/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/postgres-kit"><img src="https://img.shields.io/codecov/c/github/vapor/postgres-kit?style=plastic&logo=codecov&label=codecov"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift57up.svg" alt="Swift 5.7+"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
</p>

<br>

🐘 Non-blocking, event-driven Swift client for PostgreSQL.

### Major Releases

The table below shows a list of PostgresKit major releases alongside their compatible NIO and Swift versions.

|Version|NIO|Swift|SPM|
|-|-|-|-|
|2.0|2.0|5.2+|`from: "2.0.0"`|
|1.0|1.0|4.0+|`from: "1.0.0"`|
### Usage

Use the SPM string to easily include the dependendency in your `Package.swift` file.

```swift
.package(url: "https://github.com/vapor/postgres-kit.git", from: ...)
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.0.0")
```

### Supported Platforms
Expand Down
9 changes: 6 additions & 3 deletions Sources/PostgresKit/ConnectionPool+Postgres.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ extension EventLoopConnectionPool where Source == PostgresConnectionSource {
}
}


private struct _EventLoopGroupConnectionPoolPostgresDatabase: PostgresDatabase {
let pool: EventLoopGroupConnectionPool<PostgresConnectionSource>
let logger: Logger

var eventLoop: any EventLoop { self.pool.eventLoopGroup.any() }
var eventLoop: any EventLoop {
self.pool.eventLoopGroup.any()
}

func send(_ request: any PostgresRequest, logger: Logger) -> EventLoopFuture<Void> {
self.pool.withConnection(logger: logger) { $0.send(request, logger: logger) }
Expand All @@ -35,7 +36,9 @@ private struct _EventLoopConnectionPoolPostgresDatabase: PostgresDatabase {
let pool: EventLoopConnectionPool<PostgresConnectionSource>
let logger: Logger

var eventLoop: any EventLoop { self.pool.eventLoop }
var eventLoop: any EventLoop {
self.pool.eventLoop
}

func send(_ request: any PostgresRequest, logger: Logger) -> EventLoopFuture<Void> {
self.pool.withConnection(logger: logger) { $0.send(request, logger: logger) }
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions Sources/PostgresKit/Exports.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
#if swift(>=5.8)

@_documentation(visibility: internal) @_exported import AsyncKit
@_documentation(visibility: internal) @_exported import PostgresNIO
@_documentation(visibility: internal) @_exported import SQLKit
@_documentation(visibility: internal) @_exported import struct Foundation.URL

#else

@_exported import AsyncKit
@_exported import PostgresNIO
@_exported import SQLKit
@_exported import struct Foundation.URL

#endif
2 changes: 1 addition & 1 deletion Sources/PostgresKit/PostgresConnectionSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public struct PostgresConnectionSource: ConnectionPoolSource {
}
}

extension PostgresConnection: ConnectionPoolItem { }
extension PostgresConnection: ConnectionPoolItem {}
Loading
Loading