Skip to content

Instance Method

requestConnection(logger:on:)

Requests a pooled connection.
func requestConnection(logger: Logger? = nil, on eventLoop: (any EventLoop)? = nil) -> EventLoopFuture<Source.Connection>

Parameters

logger

For trace and debug logs.

eventLoop

Preferred event loop for the new connection.

Return Value

A future containing the requested connection.

Discussion

The connection returned by this method should be released when you are finished using it.

let conn = try pool.requestConnection(...).wait()
defer { pool.releaseConnection(conn) }
// use the connection

See withConnection(logger:on:_:) for a callback-based method that automatically releases the connection.