Extended Structure
DatabaseConfigurationFactory
We’d like to just default the context parameters of the “actual” method. Unfortunately, there are a few cases involving the UNIX domain socket initalizer where usage can resolve to either the new
SQLPostgresConfiguration-based method or the deprecated PostgresConfiguration-based method, with no obvious way to disambiguate which to call. Because the context parameters are generic, if they are defaulted, the compiler resolves the ambiguity in favor of the deprecated method (which has no generic parameters). However, by adding the non-defaulted-parameter variant which takes neither context, we’ve provided a version which has no generic parameters either, which allows the compiler to resolve the ambiguity in favor of the one with better availability (i.e. the one that isn’t deprecated).extension DatabaseConfigurationFactory
Overview
Example affected code:
_ = DatabaseConfigurationFactory.postgres(configuration: .init(unixDomainSocketPath: "", username: ""))
Topics
Type Methods
static func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, decodingContext: PostgresDecodingContext<some PostgresJSONDecoder>, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorypostgres(configuration:maxConnectionsPerEventLoop:connectionPoolTimeout:encodingContext:decodingContext:sqlLogLevel:)with theencodingContextdefaulted.static func postgres(configuration: PostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, encoder: PostgresDataEncoder, decoder: PostgresDataDecoder, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorystatic func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, encodingContext: PostgresEncodingContext<some PostgresJSONEncoder>, decodingContext: PostgresDecodingContext<some PostgresJSONDecoder>, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactoryCreate a PostgreSQL database configuration from lower-level configuration.static func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, encodingContext: PostgresEncodingContext<some PostgresJSONEncoder>, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorypostgres(configuration:maxConnectionsPerEventLoop:connectionPoolTimeout:encodingContext:decodingContext:sqlLogLevel:)with thedecodingContextdefaulted.static func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, pruneInterval: TimeAmount?, maxIdleTimeBeforePruning: TimeAmount, decodingContext: PostgresDecodingContext<some PostgresJSONDecoder>, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorystatic func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, pruneInterval: TimeAmount?, maxIdleTimeBeforePruning: TimeAmount, encodingContext: PostgresEncodingContext<some PostgresJSONEncoder>, decodingContext: PostgresDecodingContext<some PostgresJSONDecoder>, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactoryCreate a PostgreSQL database configuration from lower-level configuration.static func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, pruneInterval: TimeAmount?, maxIdleTimeBeforePruning: TimeAmount, encodingContext: PostgresEncodingContext<some PostgresJSONEncoder>, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorystatic func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, pruneInterval: TimeAmount?, maxIdleTimeBeforePruning: TimeAmount, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorypostgres(configuration:maxConnectionsPerEventLoop:connectionPoolTimeout:pruneInterval:maxIdleTimeBeforePruning:encodingContext:decodingContext:sqlLogLevel:)with bothencodingContextanddecodingContextdefaulted.static func postgres(configuration: SQLPostgresConfiguration, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorypostgres(configuration:maxConnectionsPerEventLoop:connectionPoolTimeout:encodingContext:decodingContext:sqlLogLevel:)with bothencodingContextanddecodingContextdefaulted.static func postgres(hostname: String, port: Int, username: String, password: String, database: String?, tlsConfiguration: TLSConfiguration?, maxConnectionsPerEventLoop: Int, connectionPoolTimeout: TimeAmount, encoder: PostgresDataEncoder, decoder: PostgresDataDecoder, sqlLogLevel: Logger.Level) -> DatabaseConfigurationFactorystatic postgres(url:maxConnectionsPerEventLoop:connectionPoolTimeout:decoder:sqlLogLevel:)static postgres(url:maxConnectionsPerEventLoop:connectionPoolTimeout:encoder:decoder:sqlLogLevel:)static postgres(url:maxConnectionsPerEventLoop:connectionPoolTimeout:encoder:sqlLogLevel:)static postgres(url:maxConnectionsPerEventLoop:connectionPoolTimeout:encodingContext:decodingContext:sqlLogLevel:)Create a PostgreSQL database configuration from a URL string.static postgres(url:maxConnectionsPerEventLoop:connectionPoolTimeout:pruneInterval:maxIdleTimeBeforePruning:encodingContext:decodingContext:sqlLogLevel:)Create a PostgreSQL database configuration from a URL string.