@@ -2,6 +2,7 @@ extension DatabaseConfigurationFactory {
22 public static func postgres(
33 url urlString: String ,
44 maxConnectionsPerEventLoop: Int = 1 ,
5+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
56 encoder: PostgresDataEncoder = . init( ) ,
67 decoder: PostgresDataDecoder = . init( )
78 ) throws -> DatabaseConfigurationFactory {
@@ -11,6 +12,7 @@ extension DatabaseConfigurationFactory {
1112 return try . postgres(
1213 url: url,
1314 maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
15+ connectionPoolTimeout: connectionPoolTimeout,
1416 encoder: encoder,
1517 decoder: decoder
1618 )
@@ -19,6 +21,7 @@ extension DatabaseConfigurationFactory {
1921 public static func postgres(
2022 url: URL ,
2123 maxConnectionsPerEventLoop: Int = 1 ,
24+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
2225 encoder: PostgresDataEncoder = . init( ) ,
2326 decoder: PostgresDataDecoder = . init( )
2427 ) throws -> DatabaseConfigurationFactory {
@@ -27,7 +30,8 @@ extension DatabaseConfigurationFactory {
2730 }
2831 return . postgres(
2932 configuration: configuration,
30- maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
33+ maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
34+ connectionPoolTimeout: connectionPoolTimeout
3135 )
3236 }
3337
@@ -39,6 +43,7 @@ extension DatabaseConfigurationFactory {
3943 database: String ? = nil ,
4044 tlsConfiguration: TLSConfiguration ? = nil ,
4145 maxConnectionsPerEventLoop: Int = 1 ,
46+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
4247 encoder: PostgresDataEncoder = . init( ) ,
4348 decoder: PostgresDataDecoder = . init( )
4449 ) -> DatabaseConfigurationFactory {
@@ -51,13 +56,15 @@ extension DatabaseConfigurationFactory {
5156 database: database,
5257 tlsConfiguration: tlsConfiguration
5358 ) ,
54- maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
59+ maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
60+ connectionPoolTimeout: connectionPoolTimeout
5561 )
5662 }
5763
5864 public static func postgres(
5965 configuration: PostgresConfiguration ,
6066 maxConnectionsPerEventLoop: Int = 1 ,
67+ connectionPoolTimeout: NIO . TimeAmount = . seconds( 10 ) ,
6168 encoder: PostgresDataEncoder = . init( ) ,
6269 decoder: PostgresDataDecoder = . init( )
6370 ) -> DatabaseConfigurationFactory {
@@ -66,6 +73,7 @@ extension DatabaseConfigurationFactory {
6673 middleware: [ ] ,
6774 configuration: configuration,
6875 maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
76+ connectionPoolTimeout: connectionPoolTimeout,
6977 encoder: encoder,
7078 decoder: decoder
7179 )
@@ -77,6 +85,9 @@ struct FluentPostgresConfiguration: DatabaseConfiguration {
7785 var middleware : [ AnyModelMiddleware ]
7886 let configuration : PostgresConfiguration
7987 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
8091 let encoder : PostgresDataEncoder
8192 let decoder : PostgresDataDecoder
8293
@@ -87,6 +98,7 @@ struct FluentPostgresConfiguration: DatabaseConfiguration {
8798 let pool = EventLoopGroupConnectionPool (
8899 source: db,
89100 maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
101+ requestTimeout: connectionPoolTimeout,
90102 on: databases. eventLoopGroup
91103 )
92104 return _FluentPostgresDriver (
0 commit comments