Skip to content

Commit d5e9103

Browse files
committed
add release doc blocks
1 parent e92854f commit d5e9103

29 files changed

+152
-35
lines changed

Sources/PostgreSQL/Codable/PostgreSQLDataDecoder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
public struct PostgreSQLDataDecoder {
1+
struct PostgreSQLDataDecoder {
22
/// Creates a new `PostgreSQLDataDecoder`.
3-
public init() {}
3+
init() {}
44

5-
public func decode<D>(_ type: D.Type, from data: PostgreSQLData) throws -> D where D: Decodable {
5+
func decode<D>(_ type: D.Type, from data: PostgreSQLData) throws -> D where D: Decodable {
66
if let convertible = type as? PostgreSQLDataConvertible.Type {
77
return try convertible.convertFromPostgreSQLData(data) as! D
88
}

Sources/PostgreSQL/Codable/PostgreSQLRowDecoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Decodes `Decodable` types from PostgreSQL row data.
2-
public struct PostgreSQLRowDecoder {
2+
struct PostgreSQLRowDecoder {
33
/// Creates a new `PostgreSQLRowDecoder`.
4-
public init() { }
4+
init() { }
55

66
/// Decodes a `Decodable` object from `[DataColumn: PostgreSQLData]`.
77
///

Sources/PostgreSQL/Codable/PostgreSQLValueEncoder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/// let data = try PostgreSQLDataEncoder().encode("hello")
44
/// print(data) // PostgreSQLData
55
///
6-
public struct PostgreSQLDataEncoder {
6+
struct PostgreSQLDataEncoder {
77
/// Creates a new `PostgreSQLDataEncoder`.
8-
public init() { }
8+
init() { }
99

1010
/// Encodes the supplied `Encodable` object to `PostgreSQLData`.
1111
///
@@ -15,7 +15,7 @@ public struct PostgreSQLDataEncoder {
1515
/// - parameters:
1616
/// - encodable: `Encodable` object to encode.
1717
/// - returns: Encoded `PostgreSQLData`.
18-
public func encode(_ encodable: Encodable) throws -> PostgreSQLData {
18+
func encode(_ encodable: Encodable) throws -> PostgreSQLData {
1919
if let convertible = encodable as? PostgreSQLDataConvertible {
2020
return try convertible.convertToPostgreSQLData()
2121
}

Sources/PostgreSQL/Column/PostgreSQLColumn.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public struct PostgreSQLColumn: Hashable, Equatable {
66
/// The column's name.
77
public var name: String
88

9+
/// Creates a new `PostgreSQLColumn`.
910
public init(tableOID: UInt32 = 0, name: String) {
1011
self.tableOID = tableOID
1112
self.name = name

Sources/PostgreSQL/Column/PostgreSQLDataTypeCode.swift

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,89 @@
11
/// The data type's raw object ID.
22
/// Use `select * from pg_type where oid = <idhere>;` to lookup more information.
33
public struct PostgreSQLDataFormat: Codable, Equatable, ExpressibleByIntegerLiteral {
4-
/// Recognized types
4+
/// `0`
55
public static let null = PostgreSQLDataFormat(0)
6+
/// `16`
67
public static let bool = PostgreSQLDataFormat(16)
8+
/// `17`
79
public static let bytea = PostgreSQLDataFormat(17)
10+
/// `18`
811
public static let char = PostgreSQLDataFormat(18)
12+
/// `19`
913
public static let name = PostgreSQLDataFormat(19)
14+
/// `20`
1015
public static let int8 = PostgreSQLDataFormat(20)
16+
/// `21`
1117
public static let int2 = PostgreSQLDataFormat(21)
18+
/// `23`
1219
public static let int4 = PostgreSQLDataFormat(23)
20+
/// `24`
1321
public static let regproc = PostgreSQLDataFormat(24)
22+
/// `25`
1423
public static let text = PostgreSQLDataFormat(25)
24+
/// `26`
1525
public static let oid = PostgreSQLDataFormat(26)
26+
/// `114`
1627
public static let json = PostgreSQLDataFormat(114)
28+
/// `194`
1729
public static let pg_node_tree = PostgreSQLDataFormat(194)
30+
/// `600`
1831
public static let point = PostgreSQLDataFormat(600)
32+
/// `700`
1933
public static let float4 = PostgreSQLDataFormat(700)
34+
/// `701`
2035
public static let float8 = PostgreSQLDataFormat(701)
36+
/// `1000`
2137
public static let _bool = PostgreSQLDataFormat(1000)
38+
/// `1001`
2239
public static let _bytea = PostgreSQLDataFormat(1001)
40+
/// `1002`
2341
public static let _char = PostgreSQLDataFormat(1002)
42+
/// `1003`
2443
public static let _name = PostgreSQLDataFormat(1003)
44+
/// `1005`
2545
public static let _int2 = PostgreSQLDataFormat(1005)
46+
/// `1007`
2647
public static let _int4 = PostgreSQLDataFormat(1007)
48+
/// `1009`
2749
public static let _text = PostgreSQLDataFormat(1009)
50+
/// `1016`
2851
public static let _int8 = PostgreSQLDataFormat(1016)
52+
/// `1017`
2953
public static let _point = PostgreSQLDataFormat(1017)
54+
/// `1021`
3055
public static let _float4 = PostgreSQLDataFormat(1021)
56+
/// `1022`
3157
public static let _float8 = PostgreSQLDataFormat(1022)
58+
/// `1034`
3259
public static let _aclitem = PostgreSQLDataFormat(1034)
60+
/// `1042`
3361
public static let bpchar = PostgreSQLDataFormat(1042)
62+
/// `1043`
3463
public static let varchar = PostgreSQLDataFormat(1043)
64+
/// `1082`
3565
public static let date = PostgreSQLDataFormat(1082)
66+
/// `1083`
3667
public static let time = PostgreSQLDataFormat(1083)
68+
/// `1114`
3769
public static let timestamp = PostgreSQLDataFormat(1114)
70+
/// `1115`
3871
public static let _timestamp = PostgreSQLDataFormat(1115)
72+
/// `1184`
3973
public static let timestamptz = PostgreSQLDataFormat(1184)
74+
/// `1266`
4075
public static let timetz = PostgreSQLDataFormat(1266)
76+
/// `1700`
4177
public static let numeric = PostgreSQLDataFormat(1700)
78+
/// `2278`
4279
public static let void = PostgreSQLDataFormat(2278)
80+
/// `2950`
4381
public static let uuid = PostgreSQLDataFormat(2950)
82+
/// `2951`
4483
public static let _uuid = PostgreSQLDataFormat(2951)
84+
/// `3802`
4585
public static let jsonb = PostgreSQLDataFormat(3802)
86+
/// `3807`
4687
public static let _jsonb = PostgreSQLDataFormat(3807)
4788

4889
/// See `Equatable.==`

Sources/PostgreSQL/Connection/PostgreSQLConnection+Connect.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
extension PostgreSQLConnection {
2+
/// Connects to PostgreSQL server via TCP.
23
public static func connect(
34
hostname: String = "localhost",
45
port: Int = 5432,
56
transport: TransportConfig = .cleartext,
6-
on worker: Worker,
7-
onError: @escaping (Error) -> ()
7+
on worker: Worker
88
) throws -> Future<PostgreSQLConnection> {
9-
return try connect(to: .tcp(hostname: hostname, port: port), transport: transport, on: worker, onError: onError)
9+
return try connect(to: .tcp(hostname: hostname, port: port), transport: transport, on: worker)
1010
}
1111

12+
/// Connects to PostgreSQL server specified by a `ServerAddress`.
1213
public static func connect(
1314
to serverAddress: ServerAddress,
1415
transport: TransportConfig = .cleartext,
15-
on worker: Worker,
16-
onError: @escaping (Error) -> ()
16+
on worker: Worker
1717
) throws -> Future<PostgreSQLConnection> {
18-
let handler = QueueHandler<PostgreSQLMessage, PostgreSQLMessage>(on: worker, onError: onError)
18+
let handler = QueueHandler<PostgreSQLMessage, PostgreSQLMessage>(on: worker) { error in
19+
ERROR(error.localizedDescription)
20+
}
1921
let bootstrap = ClientBootstrap(group: worker.eventLoop)
2022
// Enable SO_REUSEADDR.
2123
.channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)

Sources/PostgreSQL/Connection/PostgreSQLConnection+Query.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
extension PostgreSQLConnection {
2+
/// Runs a query, returning each row to the supplied handler.
3+
///
4+
/// try conn.query(.select(.all, from: "users")) { row in
5+
/// print(row)
6+
/// }
7+
///
8+
/// Any values bound to the `DataQuery` as placeholders will be sent as query parameters.
9+
///
10+
/// - parameters:
11+
/// - query: `Query` to execute.
12+
/// - onRow: PostgreSQL row accepting closure to handle results, if any.
13+
/// - returns: A future that signals query completion.
214
public func query(_ query: PostgreSQLQuery, _ onRow: @escaping ([PostgreSQLColumn: PostgreSQLData]) throws -> ()) -> Future<Void> {
315
return self.query(query, resultFormat: .binary, onRow)
416
}

Sources/PostgreSQL/Connection/PostgreSQLConnection+ServerAddress.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
extension PostgreSQLConnection {
22
/// Specifies how to connect to a PostgreSQL server.
33
public struct ServerAddress {
4+
/// Default PostgreSQL server address and port.
45
public static var `default`: ServerAddress {
56
return .tcp(hostname: "localhost", port: 5432)
67
}
78

9+
/// Default PostgreSQL socket file.
810
public static var socketDefault: ServerAddress {
911
return .unixSocket(path: "/tmp/.s.PGSQL.5432")
1012
}
1113

14+
/// TCP PostgreSQL address.
1215
public static func tcp(hostname: String, port: Int) -> ServerAddress {
1316
return .init(.tcp(hostname: hostname, port: port))
1417
}
1518

19+
/// Unix socket PostgreSQL address.
1620
public static func unixSocket(path: String) -> ServerAddress {
1721
return .init(.unixSocket(path: path))
1822
}
1923

24+
/// Custom PostgreSQL socket address.
2025
public static func socketAddress(_ socketAddress: SocketAddress) -> ServerAddress {
2126
return .init(.socketAddress(socketAddress))
2227
}

Sources/PostgreSQL/Connection/PostgreSQLConnection+SimpleQuery.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
extension PostgreSQLConnection {
2+
/// Performs a non-parameterized (text protocol) query to PostgreSQL.
23
public func simpleQuery(_ query: String) -> Future<Void> {
34
return operation { self._simpleQuery(query) { _ in }}
45
}
56

7+
/// Performs a non-parameterized (text protocol) query to PostgreSQL.
68
public func simpleQuery(_ query: String, _ onRow: @escaping ([PostgreSQLColumn: PostgreSQLData]) throws -> ()) -> Future<Void> {
79
return operation { self._simpleQuery(query, onRow) }
810
}

Sources/PostgreSQL/Connection/PostgreSQLConnection+TransportConfig.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import NIOOpenSSL
22

33
extension PostgreSQLConnection {
4+
/// Transport-layer security configuration for the PostgreSQL connection.
45
public struct TransportConfig {
56
/// Does not attempt to enable TLS (this is the default).
67
public static var cleartext: TransportConfig {

0 commit comments

Comments
 (0)