Initializer
init(source:maxConnections:requestTimeout:pruneInterval:maxIdleTimeBeforePruning:logger:on:)
Creates a new
EventLoopConnectionPool.init(source: Source, maxConnections: Int, requestTimeout: TimeAmount = .seconds(10), pruneInterval: TimeAmount?, maxIdleTimeBeforePruning: TimeAmount = .seconds(120), logger: Logger = .init(label: "codes.vapor.pool"), on eventLoop: any EventLoop)
Parameters
sourceCreates new connections when needed.
maxConnectionsLimits the number of connections that can be open. Defaults to 1.
requestTimeoutTimeout for requesting a new connection. Defaults to 10 seconds.
pruneIntervalHow often to check for and prune idle database connections. If
nil(the default), no pruning is performed.maxIdleTimeBeforePruningHow long a connection may remain idle before being pruned, if pruning is enabled. Defaults to 2 minutes. Ignored if
pruneIntervalisnil.loggerFor lifecycle logs.
Discussion
let pool = EventLoopConnectionPool(...)
pool.withConnection(...) { conn in
// use conn
}