Skip to content

Commit cc0201c

Browse files
authored
Spelling, grammar, punctuation, and docc warning fixes (#628)
1 parent ea1b421 commit cc0201c

37 files changed

+190
-168
lines changed

Sources/ConnectionPoolModule/ConnectionPool.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public struct ConnectionAndMetadata<Connection: PooledConnection>: Sendable {
1414

1515
/// A connection that can be pooled in a ``ConnectionPool``
1616
public protocol PooledConnection: AnyObject, Sendable {
17-
/// The connections identifier type.
17+
/// The connection's identifier type.
1818
associatedtype ID: Hashable & Sendable
1919

20-
/// The connections identifier. The identifier is passed to
20+
/// The connection's identifier. The identifier is passed to
2121
/// the connection factory method and must stay attached to
2222
/// the connection at all times. It must not change during
23-
/// the connections lifetime.
23+
/// the connection's lifetime.
2424
var id: ID { get }
2525

2626
/// A method to register closures that are invoked when the
@@ -45,25 +45,25 @@ public protocol PooledConnection: AnyObject, Sendable {
4545
func close()
4646
}
4747

48-
/// A connection id generator. Its returned connection IDs will
49-
/// be used when creating new ``PooledConnection``s
48+
/// A connection ID generator. Its returned connection IDs will
49+
/// be used when creating new ``PooledConnection``s.
5050
public protocol ConnectionIDGeneratorProtocol: Sendable {
51-
/// The connections identifier type.
51+
/// The connection's identifier type.
5252
associatedtype ID: Hashable & Sendable
5353

5454
/// The next connection ID that shall be used.
5555
func next() -> ID
5656
}
5757

58-
/// A keep alive behavior for connections maintained by the pool
58+
/// A keep-alive behavior for connections maintained by the pool.
5959
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
6060
public protocol ConnectionKeepAliveBehavior: Sendable {
61-
/// the connection type
61+
/// The connection type.
6262
associatedtype Connection: PooledConnection
6363

6464
/// The time after which a keep-alive shall
6565
/// be triggered.
66-
/// If nil is returned, keep-alive is deactivated
66+
/// If `nil` is returned, keep-alive is deactivated.
6767
var keepAliveFrequency: Duration? { get }
6868

6969
/// This method is invoked when the keep-alive shall be
@@ -75,7 +75,7 @@ public protocol ConnectionKeepAliveBehavior: Sendable {
7575
public protocol ConnectionRequestProtocol: Sendable {
7676
/// A connection lease request ID type.
7777
associatedtype ID: Hashable & Sendable
78-
/// The leased connection type
78+
/// The leased connection type.
7979
associatedtype Connection: PooledConnection
8080

8181
/// A connection lease request ID. This ID must be generated
@@ -95,7 +95,7 @@ public protocol ConnectionRequestProtocol: Sendable {
9595
public struct ConnectionPoolConfiguration: Sendable {
9696
/// The minimum number of connections to preserve in the pool.
9797
///
98-
/// If the pool is mostly idle and the remote servers closes
98+
/// If the pool is mostly idle and the remote server closes
9999
/// idle connections,
100100
/// the `ConnectionPool` will initiate new outbound
101101
/// connections proactively to avoid the number of available
@@ -111,23 +111,23 @@ public struct ConnectionPoolConfiguration: Sendable {
111111
/// The maximum number of connections for this pool, that can
112112
/// exist at any point in time. The pool can create _overflow_
113113
/// connections, if all connections are leased, and the
114-
/// `maximumConnectionHardLimit` > `maximumConnectionSoftLimit `
114+
/// `maximumConnectionHardLimit` > `maximumConnectionSoftLimit`.
115115
/// Overflow connections are closed immediately as soon as they
116116
/// become idle.
117117
public var maximumConnectionHardLimit: Int
118118

119-
/// The amount of time to pass between the first failed connection
119+
/// The amount of time after the first failed connection attempt
120120
/// before triggering the circuit breaker.
121121
public var circuitBreakerTripAfter: Duration
122122

123123
/// The time that a _preserved_ idle connection stays in the
124124
/// pool before it is closed.
125125
public var idleTimeout: Duration
126126

127-
/// Maximum number of in-progress new connection requests to run at any one time
127+
/// Maximum number of in-progress new connection requests to run at any one time.
128128
public var maximumConcurrentConnectionRequests: Int
129129

130-
/// initializer
130+
/// Creates a new connection pool configuration.
131131
public init() {
132132
self.minimumConnectionCount = 0
133133
self.maximumConnectionSoftLimit = 16
@@ -270,7 +270,7 @@ public final class ConnectionPool<
270270
}
271271

272272
/// Mark a connection as going away. Connection implementors have to call this method if the connection
273-
/// has received a close intent from the server. For example: an HTTP/2 GOWAY frame.
273+
/// has received a close intent from the server. For example: an HTTP/2 GOAWAY frame.
274274
public func connectionWillClose(_ connection: Connection) {
275275

276276
}

Sources/ConnectionPoolModule/ConnectionPoolError.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ public struct ConnectionPoolError: Error, Hashable {
1313
@inlinable
1414
init(_ base: Base) { self.base = base }
1515

16-
/// The connection requests got cancelled
16+
/// The connection request was cancelled.
1717
@inlinable
1818
public static var requestCancelled: Self {
1919
ConnectionPoolError(.requestCancelled)
2020
}
21-
/// The connection requests can't be fulfilled as the pool has already been shutdown
21+
/// The connection request can't be fulfilled because the pool has already been shut down.
2222
@inlinable
2323
public static var poolShutdown: Self {
2424
ConnectionPoolError(.poolShutdown)
2525
}
26-
/// The connection pool has failed to make a connection after a defined time
26+
/// The connection pool has failed to make a connection after a defined time.
2727
@inlinable
2828
public static var connectionCreationCircuitBreakerTripped: Self {
2929
ConnectionPoolError(.connectionCreationCircuitBreakerTripped)

Sources/ConnectionPoolModule/ConnectionPoolObservabilityDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public protocol ConnectionPoolObservabilityDelegate: Sendable {
1616
/// time and is reported via ````. The
1717
func connectSucceeded(id: ConnectionID, streamCapacity: UInt16)
1818

19-
/// The utlization of the connection changed; a stream may have been used, returned or the
19+
/// The utilization of the connection changed; a stream may have been used, returned, or the
2020
/// maximum number of concurrent streams available on the connection changed.
2121
func connectionUtilizationChanged(id:ConnectionID, streamsUsed: UInt16, streamCapacity: UInt16)
2222

Sources/ConnectionPoolModule/NIOLock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
138138
let buffer = Self.create(minimumCapacity: 1) { _ in
139139
value
140140
}
141-
// Intentionally using a force cast here to avoid a miss compiliation in 5.10.
141+
// Intentionally using a force cast here to avoid a miscompilation in 5.10.
142142
// This is as fast as an unsafeDownCast since ManagedBuffer is inlined and the optimizer
143143
// can eliminate the upcast/downcast pair
144144
let storage = buffer as! Self

Sources/ConnectionPoolModule/PoolStateMachine+ConnectionGroup.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ extension PoolStateMachine {
7373
@usableFromInline
7474
let generator: ConnectionIDGenerator
7575

76-
/// The connections states
76+
/// The connection states.
7777
@usableFromInline
7878
private(set) var connections: [ConnectionState]
7979

@@ -126,8 +126,7 @@ extension PoolStateMachine {
126126
/// Information around an idle connection.
127127
@usableFromInline
128128
struct AvailableConnectionContext {
129-
/// The connection's use. Either general purpose or for requests with `EventLoop`
130-
/// requirements.
129+
/// The connection's use: persisted, demand, or overflow.
131130
@usableFromInline
132131
var use: ConnectionUse
133132

@@ -319,7 +318,7 @@ extension PoolStateMachine {
319318
}
320319

321320
guard let index = self.findAvailableConnection() else {
322-
preconditionFailure("Stats and actual count are of.")
321+
preconditionFailure("Stats and actual count are off.")
323322
}
324323

325324
return self.leaseConnection(at: index, streams: 1)
@@ -375,7 +374,7 @@ extension PoolStateMachine {
375374
preconditionFailure("Overflow connections should never be parked.")
376375

377376
default:
378-
preconditionFailure("A connection index must not be equal or larger `self.maximumConcurrentConnectionHardLimit`")
377+
preconditionFailure("A connection index must not be equal to or larger than `self.maximumConcurrentConnectionHardLimit`")
379378
}
380379

381380
return self.connections[index].parkConnection(
@@ -573,7 +572,7 @@ extension PoolStateMachine {
573572
}
574573

575574
if index < self.minimumConcurrentConnections {
576-
// because of a race a connection might receive a idle timeout after it was moved into
575+
// because of a race a connection might receive an idle timeout after it was moved into
577576
// the persisted connections. If a connection is now persisted, we now need to ignore
578577
// the trigger
579578
return nil
@@ -590,7 +589,7 @@ extension PoolStateMachine {
590589
return nil
591590
}
592591
if index < self.minimumConcurrentConnections {
593-
// because of a race a connection might receive a idle timeout after it was moved into
592+
// because of a race a connection might receive an idle timeout after it was moved into
594593
// the persisted connections. If a connection is now persisted, we now need to ignore
595594
// the trigger
596595
return nil
@@ -784,7 +783,7 @@ extension PoolStateMachine {
784783
return nil
785784

786785
default:
787-
preconditionFailure("A connection index must not be equal or larger `self.maximumConcurrentConnectionHardLimit`")
786+
preconditionFailure("A connection index must not be equal to or larger than `self.maximumConcurrentConnectionHardLimit`")
788787
}
789788

790789
case self.minimumConcurrentConnections..<self.maximumConcurrentConnectionSoftLimit:

Sources/ConnectionPoolModule/PoolStateMachine+ConnectionState.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension PoolStateMachine {
4444
}
4545

4646
@usableFromInline
47-
/// An connection state machine about the pool's view on the connection.
47+
/// A connection state machine for the pool's view on the connection.
4848
struct ConnectionState: Sendable {
4949
@usableFromInline
5050
enum State: Sendable {
@@ -107,14 +107,14 @@ extension PoolStateMachine {
107107
}
108108
}
109109

110-
/// The pool is creating a connection. Valid transitions are to: `.backingOff`, `.idle`, and `.closed`
110+
/// The pool is creating a connection. Valid transitions are to: `.backingOff`, `.idle`, and `.closed`.
111111
case starting
112112
/// The pool is waiting to retry establishing a connection. Valid transitions are to: `.closed`.
113113
/// This means, the connection can be removed from the connections without cancelling external
114114
/// state. The connection state can then be replaced by a new one.
115115
case backingOff(Timer)
116-
/// The connection is `idle` and ready to execute a new query. Valid transitions to: `.pingpong`, `.leased`,
117-
/// `.closing` and `.closed`
116+
/// The connection is `idle` and ready to execute a new query. Valid transitions to: `.leased`,
117+
/// `.closing`, and `.closed`.
118118
case idle(Connection, maxStreams: UInt16, keepAlive: KeepAlive, idleTimer: Timer?)
119119
/// The connection is leased and executing a query. Valid transitions to: `.idle` and `.closed`
120120
case leased(Connection, usedStreams: UInt16, maxStreams: UInt16, keepAlive: KeepAlive)

Sources/ConnectionPoolModule/PoolStateMachine.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import Musl
1111
struct PoolConfiguration: Sendable {
1212
/// The minimum number of connections to preserve in the pool.
1313
///
14-
/// If the pool is mostly idle and the remote servers closes idle connections,
14+
/// If the pool is mostly idle and the remote server closes idle connections,
1515
/// the `ConnectionPool` will initiate new outbound connections proactively
1616
/// to avoid the number of available connections dropping below this number.
1717
@usableFromInline
1818
var minimumConnectionCount: Int = 0
1919

20-
/// The maximum number of connections to for this pool, to be preserved.
20+
/// The maximum number of connections for this pool to be preserved.
2121
@usableFromInline
2222
var maximumConnectionSoftLimit: Int = 10
2323

@@ -815,7 +815,7 @@ struct PoolStateMachine<
815815
extension PoolStateMachine {
816816
/// Calculates the delay for the next connection attempt after the given number of failed `attempts`.
817817
///
818-
/// Our backoff formula is: 100ms * 1.25^(attempts - 1) with 3% jitter that is capped of at 1 minute.
818+
/// Our backoff formula is: 100ms * 1.25^(attempts - 1) with 3% jitter that is capped off at 1 minute.
819819
/// This means for:
820820
/// - 1 failed attempt : 100ms
821821
/// - 5 failed attempts: ~300ms
@@ -826,10 +826,10 @@ extension PoolStateMachine {
826826
/// - 29 failed attempts: ~60s (max out)
827827
///
828828
/// - Parameter attempts: number of failed attempts in a row
829-
/// - Returns: time to wait until trying to establishing a new connection
829+
/// - Returns: time to wait until trying to establish a new connection
830830
@usableFromInline
831831
static func calculateBackoff(failedAttempt attempts: Int) -> Duration {
832-
// Our backoff formula is: 100ms * 1.25^(attempts - 1) that is capped of at 1minute
832+
// Our backoff formula is: 100ms * 1.25^(attempts - 1) that is capped off at 1 minute
833833
// This means for:
834834
// - 1 failed attempt : 100ms
835835
// - 5 failed attempts: ~300ms

Sources/PostgresNIO/Connection/PostgresConnection+Configuration.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import NIOPosix // inet_pton() et al.
33
import NIOSSL
44

55
extension PostgresConnection {
6-
/// A configuration object for a connection
6+
/// A configuration object for a connection.
77
public struct Configuration: Sendable {
88

99
// MARK: - TLS
@@ -66,7 +66,7 @@ extension PostgresConnection {
6666
public struct Options: Sendable {
6767
/// A timeout for connection attempts. Defaults to ten seconds.
6868
///
69-
/// Ignored when using a preexisting communcation channel. (See
69+
/// Ignored when using a preexisting communication channel. (See
7070
/// ``PostgresConnection/Configuration/init(establishedChannel:username:password:database:)``.)
7171
public var connectTimeout: TimeAmount
7272

@@ -169,6 +169,9 @@ extension PostgresConnection {
169169
/// - Parameters:
170170
/// - host: The hostname to connect to.
171171
/// - port: The TCP port to connect to (defaults to 5432).
172+
/// - username: The username to authenticate with.
173+
/// - password: The password to authenticate with.
174+
/// - database: The database to open. If `nil`, the client connects to the server's default database.
172175
/// - tls: The TLS mode to use.
173176
public init(host: String, port: Int = 5432, username: String, password: String?, database: String?, tls: TLS) {
174177
self.init(endpointInfo: .connectTCP(host: host, port: port), tls: tls, username: username, password: password, database: database)
@@ -177,8 +180,10 @@ extension PostgresConnection {
177180
/// Create a configuration for connecting to a server through a UNIX domain socket.
178181
///
179182
/// - Parameters:
180-
/// - path: The filesystem path of the socket to connect to.
181-
/// - tls: The TLS mode to use. Defaults to ``TLS-swift.struct/disable``.
183+
/// - unixSocketPath: The filesystem path of the socket to connect to.
184+
/// - username: The username to authenticate with.
185+
/// - password: The password to authenticate with.
186+
/// - database: The database to open. If `nil`, the client connects to the server's default database.
182187
public init(unixSocketPath: String, username: String, password: String?, database: String?) {
183188
self.init(endpointInfo: .bindUnixDomainSocket(path: unixSocketPath), tls: .disable, username: username, password: password, database: database)
184189
}
@@ -193,6 +198,9 @@ extension PostgresConnection {
193198
/// - channel: The `NIOCore/Channel` to use. The channel must already be active and connected to an
194199
/// endpoint (i.e. `NIOCore/Channel/isActive` must be `true`).
195200
/// - tls: The TLS mode to use.
201+
/// - username: The username to authenticate with.
202+
/// - password: The password to authenticate with.
203+
/// - database: The database to open. If `nil`, the client connects to the server's default database.
196204
public init(establishedChannel channel: any Channel, tls: PostgresConnection.Configuration.TLS, username: String, password: String?, database: String?) {
197205
self.init(endpointInfo: .configureChannel(channel), tls: tls, username: username, password: password, database: database)
198206
}
@@ -206,6 +214,9 @@ extension PostgresConnection {
206214
/// - Parameters:
207215
/// - channel: The `NIOCore/Channel` to use. The channel must already be active and connected to an
208216
/// endpoint (i.e. `NIOCore/Channel/isActive` must be `true`).
217+
/// - username: The username to authenticate with.
218+
/// - password: The password to authenticate with.
219+
/// - database: The database to open. If `nil`, the client connects to the server's default database.
209220
public init(establishedChannel channel: any Channel, username: String, password: String?, database: String?) {
210221
self.init(establishedChannel: channel, tls: .disable, username: username, password: password, database: database)
211222
}

Sources/PostgresNIO/Connection/PostgresConnection+CopyFrom.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public struct PostgresCopyFromWriter: Sendable {
3131

3232
/// Send data for a `COPY ... FROM STDIN` operation to the backend.
3333
///
34-
/// - Throws: If an error occurs during the write of if the backend sent an `ErrorResponse` during the copy
35-
/// operation, eg. to indicate that a **previous** `write` call had an invalid format.
34+
/// - Throws: If an error occurs during the write or if the backend sent an `ErrorResponse` during the copy
35+
/// operation, e.g. to indicate that a **previous** `write` call had an invalid format.
3636
public func write(_ byteBuffer: ByteBuffer) async throws {
3737
// Check for cancellation. This is cheap and makes sure that we regularly check for cancellation in the
3838
// `writeData` closure. It is likely that the user would forget to do so.
@@ -100,7 +100,7 @@ public struct PostgresCopyFromWriter: Sendable {
100100

101101
/// Specifies the format in which data is transferred to the backend in a COPY operation.
102102
///
103-
/// See the Postgres documentation at https://www.postgresql.org/docs/current/sql-copy.html for the option's meanings
103+
/// See the Postgres documentation at https://www.postgresql.org/docs/current/sql-copy.html for the options' meanings
104104
/// and their default values.
105105
public struct PostgresCopyFromFormat: Sendable {
106106
/// Options that can be used to modify the `text` format of a COPY operation.
@@ -168,6 +168,9 @@ extension PostgresConnection {
168168
/// - table: The name of the table into which to copy the data.
169169
/// - columns: The name of the columns to copy. If an empty array is passed, all columns are assumed to be copied.
170170
/// - format: Options that specify the format of the data that is produced by `writeData`.
171+
/// - logger: The `Logger` to log into for the operation.
172+
/// - file: The file the operation was started in. Used for better error reporting.
173+
/// - line: The line the operation was started in. Used for better error reporting.
171174
/// - writeData: Closure that produces the data for the table, to be streamed to the backend. Call `write` on the
172175
/// writer provided by the closure to send data to the backend and return from the closure once all data is sent.
173176
/// Throw an error from the closure to fail the data transfer. The error thrown by the closure will be rethrown

0 commit comments

Comments
 (0)