@@ -2,6 +2,7 @@ extension DatabaseConfigurationFactory {
2
2
public static func postgres(
3
3
url urlString: String ,
4
4
maxConnectionsPerEventLoop: Int = 1 ,
5
+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
5
6
encoder: PostgresDataEncoder = . init( ) ,
6
7
decoder: PostgresDataDecoder = . init( )
7
8
) throws -> DatabaseConfigurationFactory {
@@ -11,6 +12,7 @@ extension DatabaseConfigurationFactory {
11
12
return try . postgres(
12
13
url: url,
13
14
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
15
+ connectionPoolTimeout: connectionPoolTimeout,
14
16
encoder: encoder,
15
17
decoder: decoder
16
18
)
@@ -19,6 +21,7 @@ extension DatabaseConfigurationFactory {
19
21
public static func postgres(
20
22
url: URL ,
21
23
maxConnectionsPerEventLoop: Int = 1 ,
24
+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
22
25
encoder: PostgresDataEncoder = . init( ) ,
23
26
decoder: PostgresDataDecoder = . init( )
24
27
) throws -> DatabaseConfigurationFactory {
@@ -27,7 +30,8 @@ extension DatabaseConfigurationFactory {
27
30
}
28
31
return . postgres(
29
32
configuration: configuration,
30
- maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
33
+ maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
34
+ connectionPoolTimeout: connectionPoolTimeout
31
35
)
32
36
}
33
37
@@ -39,6 +43,7 @@ extension DatabaseConfigurationFactory {
39
43
database: String ? = nil ,
40
44
tlsConfiguration: TLSConfiguration ? = nil ,
41
45
maxConnectionsPerEventLoop: Int = 1 ,
46
+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
42
47
encoder: PostgresDataEncoder = . init( ) ,
43
48
decoder: PostgresDataDecoder = . init( )
44
49
) -> DatabaseConfigurationFactory {
@@ -51,13 +56,15 @@ extension DatabaseConfigurationFactory {
51
56
database: database,
52
57
tlsConfiguration: tlsConfiguration
53
58
) ,
54
- maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
59
+ maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
60
+ connectionPoolTimeout: connectionPoolTimeout
55
61
)
56
62
}
57
63
58
64
public static func postgres(
59
65
configuration: PostgresConfiguration ,
60
66
maxConnectionsPerEventLoop: Int = 1 ,
67
+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
61
68
encoder: PostgresDataEncoder = . init( ) ,
62
69
decoder: PostgresDataDecoder = . init( )
63
70
) -> DatabaseConfigurationFactory {
@@ -66,6 +73,7 @@ extension DatabaseConfigurationFactory {
66
73
middleware: [ ] ,
67
74
configuration: configuration,
68
75
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
76
+ connectionPoolTimeout: connectionPoolTimeout,
69
77
encoder: encoder,
70
78
decoder: decoder
71
79
)
@@ -77,6 +85,9 @@ struct FluentPostgresConfiguration: DatabaseConfiguration {
77
85
var middleware : [ AnyModelMiddleware ]
78
86
let configuration : PostgresConfiguration
79
87
let maxConnectionsPerEventLoop : Int
88
+ /// The amount of time to wait for a connection from
89
+ /// the connection pool before timing out.
90
+ let connectionPoolTimeout : NIO . TimeAmount
80
91
let encoder : PostgresDataEncoder
81
92
let decoder : PostgresDataDecoder
82
93
@@ -87,6 +98,7 @@ struct FluentPostgresConfiguration: DatabaseConfiguration {
87
98
let pool = EventLoopGroupConnectionPool (
88
99
source: db,
89
100
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
101
+ requestTimeout: connectionPoolTimeout,
90
102
on: databases. eventLoopGroup
91
103
)
92
104
return _FluentPostgresDriver (
0 commit comments