Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 095bc5a

Browse files
authored
Some minor cleanup (#224)
* Bump Swift minimum to 5.10, update README, update CI, remove unneeded explicit AsyncKit dependency (it's exported by PostgresKit), add .editorconfig and .swift-format * Run swift-format on most of the code * Remove no-longer-needed Sendable workaround * Fix a couple of CI typos
1 parent fd57101 commit 095bc5a

15 files changed

+341
-210
lines changed

β€Ž.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.swift]
2+
indent_style = space
3+
indent_size = 4
4+
tab_width = 4
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+

β€Ž.github/workflows/test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
api-breakage:
2727
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
2828
runs-on: ubuntu-latest
29-
container: swift:jammy
29+
container: swift:noble
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@v4
@@ -42,18 +42,18 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
include:
45-
- postgres-image-a: 'postgres:13'
46-
postgres-image-b: 'postgres:14'
45+
- postgres-image-a: 'postgres:12'
46+
postgres-image-b: 'postgres:13'
4747
postgres-auth: 'trust'
48-
swift-image: 'swift:5.9-focal'
49-
- postgres-image-a: 'postgres:15'
50-
postgres-image-b: 'postgres:16'
51-
postgres-auth: 'md5'
5248
swift-image: 'swift:5.10-jammy'
53-
- postgres-image-a: 'postgres:15'
54-
postgres-image-b: 'postgres:16'
49+
- postgres-image-a: 'postgres:14'
50+
postgres-image-b: 'postgres:15'
51+
postgres-auth: 'md5'
52+
swift-image: 'swift:6.0-noble'
53+
- postgres-image-a: 'postgres:16'
54+
postgres-image-b: 'postgres:17'
5555
postgres-auth: 'scram-sha-256'
56-
swift-image: 'swift:6.0-jammy'
56+
swift-image: 'swift:6.1-noble'
5757
container: ${{ matrix.swift-image }}
5858
runs-on: ubuntu-latest
5959
services:
@@ -89,8 +89,8 @@ jobs:
8989
fail-fast: false
9090
matrix:
9191
include:
92-
- macos-version: macos-14
93-
xcode-version: latest
92+
- macos-version: macos-15
93+
xcode-version: latest-stable
9494
runs-on: ${{ matrix.macos-version }}
9595
env:
9696
LOG_LEVEL: debug
@@ -106,7 +106,7 @@ jobs:
106106
run: |
107107
brew upgrade || true
108108
export PATH="$(brew --prefix)/opt/postgresql@16/bin:$PATH" PGDATA=/tmp/vapor-postgres-test PGUSER="${POSTGRES_USER_A}"
109-
(brew unlink postgresql@14 || true) && brew install postgresql@16 && brew link --force postgresql@16
109+
brew install postgresql@17 && brew link --force postgresql@17
110110
initdb --locale=C --auth-host "scram-sha-256" -U "${POSTGRES_USER_A}" --pwfile=<(echo "${POSTGRES_PASSWORD_A}")
111111
pg_ctl start --wait
112112
PGPASSWORD="${POSTGRES_PASSWORD_A}" createdb -w -O "${POSTGRES_USER_A}" "${POSTGRES_DB_A}"

β€Ž.swift-format

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentConditionalCompilationBlocks" : false,
6+
"indentSwitchCaseLabels" : false,
7+
"indentation" : {
8+
"spaces" : 4
9+
},
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : false,
13+
"lineBreakBeforeEachGenericRequirement" : false,
14+
"lineBreakBetweenDeclarationAttributes" : false,
15+
"lineLength" : 150,
16+
"maximumBlankLines" : 1,
17+
"multiElementCollectionTrailingCommas" : true,
18+
"noAssignmentInExpressions" : {
19+
"allowedFunctions" : [
20+
]
21+
},
22+
"prioritizeKeepingFunctionOutputTogether" : false,
23+
"reflowMultilineStringLiterals" : {
24+
"never" : {
25+
}
26+
},
27+
"respectsExistingLineBreaks" : true,
28+
"rules" : {
29+
"AllPublicDeclarationsHaveDocumentation" : false,
30+
"AlwaysUseLiteralForEmptyCollectionInit" : true,
31+
"AlwaysUseLowerCamelCase" : true,
32+
"AmbiguousTrailingClosureOverload" : true,
33+
"AvoidRetroactiveConformances" : true,
34+
"BeginDocumentationCommentWithOneLineSummary" : false,
35+
"DoNotUseSemicolons" : true,
36+
"DontRepeatTypeInStaticProperties" : true,
37+
"FileScopedDeclarationPrivacy" : true,
38+
"FullyIndirectEnum" : true,
39+
"GroupNumericLiterals" : true,
40+
"IdentifiersMustBeASCII" : true,
41+
"NeverForceUnwrap" : false,
42+
"NeverUseForceTry" : false,
43+
"NeverUseImplicitlyUnwrappedOptionals" : false,
44+
"NoAccessLevelOnExtensionDeclaration" : true,
45+
"NoAssignmentInExpressions" : true,
46+
"NoBlockComments" : true,
47+
"NoCasesWithOnlyFallthrough" : true,
48+
"NoEmptyLinesOpeningClosingBraces" : false,
49+
"NoEmptyTrailingClosureParentheses" : true,
50+
"NoLabelsInCasePatterns" : true,
51+
"NoLeadingUnderscores" : false,
52+
"NoParensAroundConditions" : true,
53+
"NoPlaygroundLiterals" : true,
54+
"NoVoidReturnOnFunctionSignature" : true,
55+
"OmitExplicitReturns" : false,
56+
"OneCasePerLine" : true,
57+
"OneVariableDeclarationPerLine" : true,
58+
"OnlyOneTrailingClosureArgument" : true,
59+
"OrderedImports" : true,
60+
"ReplaceForEachWithForLoop" : true,
61+
"ReturnVoidInsteadOfEmptyTuple" : true,
62+
"TypeNamesShouldBeCapitalized" : true,
63+
"UseEarlyExits" : true,
64+
"UseExplicitNilCheckInConditions" : true,
65+
"UseLetInEveryBoundCaseVariable" : true,
66+
"UseShorthandTypeNames" : true,
67+
"UseSingleLinePropertyGetter" : true,
68+
"UseSynthesizedInitializer" : true,
69+
"UseTripleSlashForDocumentationComments" : true,
70+
"UseWhereClausesInForLoops" : false,
71+
"ValidateDocumentationComments" : false
72+
},
73+
"spacesAroundRangeFormationOperators" : true,
74+
"spacesBeforeEndOfLineComments" : 1,
75+
"tabWidth" : 4,
76+
"version" : 1
77+
}

β€ŽPackage.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:5.10
22
import PackageDescription
33

44
let package = Package(
@@ -13,15 +13,13 @@ let package = Package(
1313
.library(name: "FluentPostgresDriver", targets: ["FluentPostgresDriver"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"),
1716
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.49.0"),
1817
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.13.4"),
1918
],
2019
targets: [
2120
.target(
2221
name: "FluentPostgresDriver",
2322
dependencies: [
24-
.product(name: "AsyncKit", package: "async-kit"),
2523
.product(name: "FluentKit", package: "fluent-kit"),
2624
.product(name: "FluentSQL", package: "fluent-kit"),
2725
.product(name: "PostgresKit", package: "postgres-kit"),

β€ŽREADME.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
<p align="center">
2-
<picture>
3-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/fluent-postgres-driver/assets/1130717/c2350b70-aaf1-43e1-ab79-86fc88ba8da4">
4-
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/fluent-postgres-driver/assets/1130717/dfc94dc2-281b-4e54-be86-549813496373">
5-
<img src="https://github.com/vapor/fluent-postgres-driver/assets/1130717/dfc94dc2-281b-4e54-be86-549813496373" height="96" alt="FluentPostgresDriver">
6-
</picture>
2+
<img src="https://design.vapor.codes/images/vapor-fluentpostgresdriver.svg" height="96" alt="FluentPostgresDriver">
73
<br>
84
<br>
95
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
106
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
117
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
128
<a href="https://github.com/vapor/fluent-postgres-driver/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/fluent-postgres-driver/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
139
<a href="https://codecov.io/github/vapor/fluent-postgres-driver"><img src="https://img.shields.io/codecov/c/github/vapor/fluent-postgres-driver?style=plastic&logo=codecov&label=codecov"></a>
14-
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
10+
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift510up.svg" alt="Swift 5.10+"></a>
1511
</p>
1612

1713
<br>

β€ŽSources/FluentPostgresDriver/Deprecations/FluentPostgresConfiguration+Deprecated.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import Logging
21
import FluentKit
3-
import AsyncKit
4-
import NIOCore
5-
import NIOSSL
62
import Foundation
3+
import Logging
4+
import NIOCore
75
import PostgresKit
86
import PostgresNIO
97

β€ŽSources/FluentPostgresDriver/Docs.docc/theme-settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
"fluentpsqldriver": "#336791",
99
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-fluentpsqldriver) 30%, #000 100%)",
1010
"documentation-intro-accent": "var(--color-fluentpsqldriver)",
11+
"documentation-intro-eyebrow": "white",
12+
"documentation-intro-figure": "white",
13+
"documentation-intro-title": "white",
1114
"logo-base": { "dark": "#fff", "light": "#000" },
1215
"logo-shape": { "dark": "#000", "light": "#fff" },
1316
"fill": { "dark": "#000", "light": "#fff" }
1417
},
15-
"icons": { "technology": "/fluentpostgresdriver/images/vapor-fluentpostgresdriver-logo.svg" }
18+
"icons": { "technology": "/fluentpostgresdriver/images/FluentPostgresDriver/vapor-fluentpostgresdriver-logo.svg" }
1619
},
1720
"features": {
1821
"quickNavigation": { "enable": true },

β€ŽSources/FluentPostgresDriver/FluentPostgresConfiguration.swift

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import Logging
2-
import FluentKit
31
import AsyncKit
4-
import NIOCore
5-
import NIOSSL
2+
import FluentKit
63
import Foundation
4+
import Logging
5+
import NIOCore
76
import PostgresKit
87
import PostgresNIO
98

@@ -31,7 +30,8 @@ extension DatabaseConfigurationFactory {
3130
configuration: try .init(url: urlString),
3231
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
3332
connectionPoolTimeout: connectionPoolTimeout,
34-
encodingContext: encodingContext, decodingContext: decodingContext,
33+
encodingContext: encodingContext,
34+
decodingContext: decodingContext,
3535
sqlLogLevel: sqlLogLevel
3636
)
3737
}
@@ -59,7 +59,8 @@ extension DatabaseConfigurationFactory {
5959
configuration: try .init(url: url),
6060
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
6161
connectionPoolTimeout: connectionPoolTimeout,
62-
encodingContext: encodingContext, decodingContext: decodingContext,
62+
encodingContext: encodingContext,
63+
decodingContext: decodingContext,
6364
sqlLogLevel: sqlLogLevel
6465
)
6566
}
@@ -81,22 +82,19 @@ extension DatabaseConfigurationFactory {
8182
decodingContext: PostgresDecodingContext<some PostgresJSONDecoder>,
8283
sqlLogLevel: Logger.Level = .debug
8384
) -> DatabaseConfigurationFactory {
84-
let configuration = FakeSendable(wrappedValue: configuration)
85-
86-
return .init {
85+
.init {
8786
FluentPostgresConfiguration(
8887
configuration: configuration,
8988
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
9089
connectionPoolTimeout: connectionPoolTimeout,
91-
encodingContext: encodingContext, decodingContext: decodingContext,
90+
encodingContext: encodingContext,
91+
decodingContext: decodingContext,
9292
sqlLogLevel: sqlLogLevel
9393
)
9494
}
9595
}
9696
}
9797

98-
fileprivate struct FakeSendable<T>: @unchecked Sendable { let wrappedValue: T }
99-
10098
/// We'd like to just default the context parameters of the "actual" method. Unfortunately, there are a few
10199
/// cases involving the UNIX domain socket initalizer where usage can resolve to either the new
102100
/// `SQLPostgresConfiguration`-based method or the deprecated `PostgresConfiguration`-based method, with no
@@ -170,22 +168,22 @@ extension DatabaseConfigurationFactory {
170168
/// The actual concrete configuration type produced by a configuration factory.
171169
struct FluentPostgresConfiguration<E: PostgresJSONEncoder, D: PostgresJSONDecoder>: DatabaseConfiguration {
172170
var middleware: [any AnyModelMiddleware] = []
173-
fileprivate let configuration: FakeSendable<SQLPostgresConfiguration>
171+
fileprivate let configuration: SQLPostgresConfiguration
174172
let maxConnectionsPerEventLoop: Int
175173
let connectionPoolTimeout: TimeAmount
176174
let encodingContext: PostgresEncodingContext<E>
177175
let decodingContext: PostgresDecodingContext<D>
178176
let sqlLogLevel: Logger.Level
179177

180178
func makeDriver(for databases: Databases) -> any DatabaseDriver {
181-
let connectionSource = PostgresConnectionSource(sqlConfiguration: self.configuration.wrappedValue)
179+
let connectionSource = PostgresConnectionSource(sqlConfiguration: self.configuration)
182180
let elgPool = EventLoopGroupConnectionPool(
183181
source: connectionSource,
184182
maxConnectionsPerEventLoop: self.maxConnectionsPerEventLoop,
185183
requestTimeout: self.connectionPoolTimeout,
186184
on: databases.eventLoopGroup
187185
)
188-
186+
189187
return _FluentPostgresDriver(
190188
pool: elgPool,
191189
encodingContext: self.encodingContext,

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /