You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor connection creation from composeable ConnectionStrategy into composeable ConnectionFunctions and a parameter-less ConnectionStrategy that holds all connection target details.
Refactor SSL fallback into ConnectionFunction as SSL is part of the initial handshake. Move startup options into ConnectionSettings.
Simplify sink subscriptions into Flux composition for easier synchronization of closed connections. Add duration style parser.
Add license headers and since tags, update documentation.
[#120][resolves#474][#203]
Signed-off-by: Mark Paluch <[email protected]>
| `noticeLogLevel` | Log level for error responses. Any of `OFF`, `DEBUG`, `INFO`, `WARN` or `ERROR` Defaults to `DEBUG`. _(Optional)_
90
-
| `preferAttachedBuffers` |Configure whether codecs should prefer attached data buffers. The default is `false`, meaning that codecs will copy data from the input buffer into a byte array. Enabling attached buffers requires consumption of values such as `Json` to avoid memory leaks.
| `protocol` | Protocol specifier. Empty to use single-host operations. Supported: `failover` for multi-server failover operations. _(Optional)_
76
+
| `host` | Server hostname to connect to. May contain a comma-separated list of hosts with ports when using the `failover` protocol.
77
+
| `port` | Server port to connect to. Defaults to `5432`. _(Optional)_
78
+
| `socket` | Unix Domain Socket path to connect to as alternative to TCP. _(Optional)_
79
+
| `username` | Login username.
80
+
| `password` | Login password. _(Optional when using TLS Certificate authentication)_
81
+
| `database` | Database to select. _(Optional)_
82
+
| `applicationName` | The name of the application connecting to the database. Defaults to `r2dbc-postgresql`. _(Optional)_
83
+
| `autodetectExtensions` | Whether to auto-detect and register `Extension`s from the class path. Defaults to `true`. _(Optional)_
84
+
| `compatibilityMode` | Enable compatibility mode for cursored fetching. Required when using newer pgpool versions. Defaults to `false`. _(Optional)_
85
+
| `errorResponseLogLevel` | Log level for error responses. Any of `OFF`, `DEBUG`, `INFO`, `WARN` or `ERROR` Defaults to `DEBUG`. _(Optional)_
86
+
| `extensions` | Collection of `Extension` to provide additional extensions when creating a connection factory. Defaults to empty. _(Optional)_
87
+
| `fetchSize` | The default number of rows to return when fetching results. Defaults to `0` for unlimited. _(Optional)_
88
+
| `forceBinary` | Whether to force binary transfer. Defaults to `false`. _(Optional)_
89
+
| `hostRecheckTime` | Host status recheck time when using multi-server operations. Defaults to `10 seconds`. _(Optional)_
90
+
| `loadBalanceHosts` | Whether to shuffle the list of given hostnames before connect when using multi-server operations. Defaults to `true. _(Optional)_
91
+
| `loopResources` | TCP/Socket LoopResources (depends on the endpoint connection type). _(Optional)_
| `noticeLogLevel` | Log level for error responses. Any of `OFF`, `DEBUG`, `INFO`, `WARN` or `ERROR` Defaults to `DEBUG`. _(Optional)_
94
+
| `preferAttachedBuffers` |Configure whether codecs should prefer attached data buffers. The default is `false`, meaning that codecs will copy data from the input buffer into a byte array. Enabling attached buffers requires consumption of values such as `Json` to avoid memory leaks.
91
95
| `preparedStatementCacheQueries` | Determine the number of queries that are cached in each connection. The default is `-1`, meaning there's no limit. The value of `0` disables the cache. Any other value specifies the cache size.
92
-
| `options` | A `Map<String, String>` of connection parameters. These are applied to each database connection created by the `ConnectionFactory`. Useful for setting generic [PostgreSQL connection parameters][psql-runtime-config]. _(
96
+
| `options`| A `Map<String, String>` of connection parameters. These are applied to each database connection created by the `ConnectionFactory`. Useful for setting generic [PostgreSQL connection parameters][psql-runtime-config]. _(
93
97
Optional)_
94
-
| `schema` | The search path to set. _(Optional)_
95
-
| `sslMode` | SSL mode to use, see `SSLMode` enum. Supported values: `DISABLE`, `ALLOW`, `PREFER`, `REQUIRE`, `VERIFY_CA`, `VERIFY_FULL`, `TUNNEL`. _(Optional)_
96
-
| `sslRootCert` | Path to SSL CA certificate in PEM format. Can be also a resource path. _(Optional)_
97
-
| `sslKey` | Path to SSL key for TLS authentication in PEM format. Can be also a resource path. _(Optional)_
98
-
| `sslCert` | Path to SSL certificate for TLS authentication in PEM format. Can be also a resource path. _(Optional)_
99
-
| `sslPassword` | Key password to decrypt SSL key. _(Optional)_
| `targetServerType` | Type of server to use when using multi-host operations. Supported values: `ANY`, `PRIMARY`, `SECONDARY`, `PREFER_SECONDARY`. Defaults to `ANY`. _(Optional)_
107
+
| `tcpNoDelay` | Enable/disable TCP NoDelay. Enabled by default. _(Optional)_
108
+
| `tcpKeepAlive` | Enable/disable TCP KeepAlive. Disabled by default. _(Optional)_
104
109
105
110
**Programmatic Configuration**
106
111
@@ -167,6 +172,23 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
167
172
</repository>
168
173
```
169
174
175
+
## Connection Fail-over
176
+
177
+
To support simple connection fail-over it is possible to define multiple endpoints (host and port pairs) in the connection url separated by commas. The driver will try once to connect to each of them
178
+
in order until the connection succeeds. If none succeeds a normal connection exception is thrown. Make sure to specify the `failover` protocol.
For example an application can create two connection pools. One data source is for writes, another for reads. The write pool limits connections only to a primary node:
* Interface defining a function how to connect to a single {@link SocketAddress endpoint} applying {@link ConnectionSettings}.
27
+
* <p>A connection function is a low-level utility whose result is a valid {@link Client} object. Connection functions may perform multiple connection attempts (e.g. SSL handshake downgrading).
28
+
* Topology discovery is a higher-level concept that is typically encapsulated as part of a {@link ConnectionStrategy}.
29
+
*
30
+
* @see ConnectionStrategy
31
+
* @since 1.0
32
+
*/
33
+
@FunctionalInterface
34
+
publicinterfaceConnectionFunction {
35
+
36
+
/**
37
+
* Establish a connection to the given {@link SocketAddress endpoint} applying {@link ConnectionSettings}.
38
+
*
39
+
* @param endpoint the endpoint to connect to
40
+
* @param settings the settings to apply
41
+
* @return a mono that connects to the given endpoint upon subscription
42
+
* @throws IllegalArgumentException if {@code socketAddress} or {@code settings} is {@code null}
* Interface defining a connection strategy on how to obtain a Postgres {@link Client} object.
24
+
* <p>
25
+
* Typically, connection strategies use a {@link ConnectionFunction} and are configured with a connection endpoint to establish a client connection to the target server as the {@link #connect()}
26
+
* method does not take any parameters.
27
+
*
28
+
* @see ConnectionFunction
29
+
* @since 1.0
30
+
*/
31
+
@FunctionalInterface
11
32
publicinterfaceConnectionStrategy {
12
33
34
+
/**
35
+
* Establish a connection to a target server that is determined by this connection strategy.
36
+
*
37
+
* @return a mono that initiates the connection upon subscription.
* Factory methods to obtain a {@link ConnectionStrategy} object.
34
+
*
35
+
* @since 1.0
36
+
*/
37
+
finalclassConnectionStrategyFactory {
38
+
39
+
/**
40
+
* Create a {@link ConnectionStrategy} that is able to connect to the specified {@link PostgresqlConnectionConfiguration configuration}.
41
+
*
42
+
* @param connectionFunction the raw connection function to use to create a {@link Client}. The connection function is enhanced during the connect phase to perform a handshake with the database.
0 commit comments