Skip to content

Type Method

postgres(url:maxConnectionsPerEventLoop:connectionPoolTimeout:pruneInterval:maxIdleTimeBeforePruning:encodingContext:decodingContext:sqlLogLevel:)

Create a PostgreSQL database configuration from a URL string.
static func postgres(url urlString: String, maxConnectionsPerEventLoop: Int = 1, connectionPoolTimeout: TimeAmount = .seconds(10), pruneInterval: TimeAmount?, maxIdleTimeBeforePruning: TimeAmount = .seconds(120), encodingContext: PostgresEncodingContext<some PostgresJSONEncoder> = .default, decodingContext: PostgresDecodingContext<some PostgresJSONDecoder> = .default, sqlLogLevel: Logger.Level = .debug) throws -> DatabaseConfigurationFactory

Parameters

urlString

The URL describing the connection, as a string.

maxConnectionsPerEventLoop

Maximum number of connections to open per event loop.

connectionPoolTimeout

Maximum time to wait for a connection to become available per request.

pruneInterval

How often to check for and prune idle database connections. If nil (the default), no pruning is performed.

maxIdleTimeBeforePruning

How long a connection may remain idle before being pruned, if pruning is enabled. Defaults to 2 minutes. Ignored if pruneInterval is nil.

encodingContext

Encoding context to use for serializing data.

decodingContext

Decoding context to use for deserializing data.

sqlLogLevel

Level at which to log SQL queries.

Discussion

See PostgresKit/SQLPostgresConfiguration/init(url:) for the allowed URL format.