Class
EventLoopConnectionPool
Holds a collection of active connections that can be requested and later released back into the pool.
final class EventLoopConnectionPool<Source> where Source : ConnectionPoolSource
Overview
Connection pools are used to offset the overhead of creating new connections. Newly opened connections are returned back to the pool and can be re-used until they close.
New connections are created as needed until the maximum configured connection limit is reached. After the maximum is reached, no new connections will be created unless existing connections are closed.
let pool = EventLoopConnectionPool(...)
pool.withConnection(...) { conn in
// use conn
}
Topics
Initializers
init(source:maxConnections:requestTimeout:logger:on:)Creates a newEventLoopConnectionPool.init(source:maxConnections:requestTimeout:pruneInterval:maxIdleTimeBeforePruning:logger:on:)Creates a newEventLoopConnectionPool.
Instance Properties
Instance Methods
close()Closes the connection pool.releaseConnection(_:)Releases a connection back to the pool. Use withrequestConnection().releaseConnection(_:logger:)Releases a connection back to the pool. Use withrequestConnection(logger:).requestConnection()Requests a pooled connection.requestConnection(logger:)Requests a pooled connection.withConnection(_:)Fetches a pooled connection for the lifetime of the closure.withConnection(logger:_:)Fetches a pooled connection for the lifetime of the closure.
See Also
Legacy connection pools
EventLoopGroupConnectionPoolHolds a collection of connection pools for eachEventLoopon anEventLoopGroup.ConnectionPoolSourceSource of new connections forEventLoopGroupConnectionPool.ConnectionPoolItemItem managed by a connection pool.ConnectionPoolErrorErrors thrown byEventLoopGroupConnectionPoolandEventLoopConnectionPoolregarding state.ConnectionPoolTimeoutErrorErrors thrown byEventLoopGroupConnectionPoolandEventLoopConnectionPoolregarding timeouts.