Class
EventLoopGroupConnectionPool
Holds a collection of connection pools for each
EventLoop on an EventLoopGroup.final class EventLoopGroupConnectionPool<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 = EventLoopGroupConnectionPool(...)
pool.withConnection { conn in
// use conn
}
Topics
Initializers
init(source:maxConnectionsPerEventLoop:requestTimeout:logger:on:)Creates a newEventLoopGroupConnectionPool.init(source:maxConnectionsPerEventLoop:requestTimeout:pruneInterval:maxIdleTimeBeforePruning:logger:on:)Creates a newEventLoopGroupConnectionPool.
Instance Properties
eventLoopGroupEvent loop source when not specified.maxConnectionsPerEventLoopLimits the maximum number of connections that can be open at a given time for a single connection pool.sourceCreates new connections when needed. SeeConnectionPoolSource.
Instance Methods
pool(for:)Returns theEventLoopConnectionPoolfor a specific event loop.releaseConnection(_:logger:)Releases a connection back to the pool. Use withrequestConnection(logger:on:).requestConnection(logger:on:)Requests a pooled connection.shutdown()Closes the connection pool.shutdownAsync()Closes the connection pool.shutdownGracefully(_:)Closes the connection pool.syncShutdownGracefully()Closes the connection pool.withConnection(logger:on:_:)Fetches a pooled connection for the lifetime of the closure.
See Also
Legacy connection pools
EventLoopConnectionPoolHolds a collection of active connections that can be requested and later released back into the pool.ConnectionPoolSourceSource of new connections forEventLoopGroupConnectionPool.ConnectionPoolItemItem managed by a connection pool.ConnectionPoolErrorErrors thrown byEventLoopGroupConnectionPoolandEventLoopConnectionPoolregarding state.ConnectionPoolTimeoutErrorErrors thrown byEventLoopGroupConnectionPoolandEventLoopConnectionPoolregarding timeouts.