Skip to content

Commit 59295fc

Browse files
authored
Merge pull request #174 from killaitis/master
Added documentation for options parameter in ConnectionConfiguration [#174]
2 parents ca15711 + 63991cd commit 59295fc

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,18 @@ Publisher<? extends Connection> connectionPublisher = connectionFactory.create()
4242
**Programmatic Connection Factory Discovery**
4343

4444
```java
45+
Map<String, String> options = new HashMap<>();
46+
options.put("lock_timeout", "10s");
47+
options.put("statement_timeout", "5m");
48+
4549
ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder()
4650
.option(DRIVER, "postgresql")
4751
.option(HOST, "...")
48-
.option(PORT, "...") // optional, defaults to 5432
52+
.option(PORT, 5432) // optional, defaults to 5432
4953
.option(USER, "...")
5054
.option(PASSWORD, "...")
5155
.option(DATABASE, "...") // optional
56+
.option(OPTIONS, options) // optional
5257
.build());
5358

5459
Publisher<? extends Connection> connectionPublisher = connectionFactory.create();
@@ -70,6 +75,7 @@ Mono<Connection> connectionMono = Mono.from(connectionFactory.create());
7075
| `database` | Database to select. _(Optional)_
7176
| `applicationName` | The name of the application connecting to the database. Defaults to `r2dbc-postgresql`. _(Optional)_
7277
| `autodetectExtensions` | Whether to auto-detect and register `Extension`s from the class path. Defaults to `true`. _(Optional)_
78+
| `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]. _(Optional)_
7379
| `schema` | The schema to set. _(Optional)_
7480
| `sslMode` | SSL mode to use, see `SSLMode` enum. Supported values: `DISABLE`, `ALLOW`, `PREFER`, `REQUIRE`, `VERIFY_CA`, `VERIFY_FULL`. _(Optional)_
7581
| `sslRootCert` | Path to SSL CA certificate in PEM format. _(Optional)_
@@ -81,12 +87,16 @@ Mono<Connection> connectionMono = Mono.from(connectionFactory.create());
8187
**Programmatic Configuration**
8288

8389
```java
90+
Map<String, String> options = new HashMap<>();
91+
options.put("lock_timeout", "10s");
92+
8493
ConnectionFactory connectionFactory = new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
8594
.host("...")
86-
.port("..."). // optional, defaults to 5432
95+
.port(5432) // optional, defaults to 5432
8796
.username("...")
8897
.password("...")
8998
.database("...") // optional
99+
.options(options) // optional
90100
.build());
91101

92102
Mono<Connection> mono = connectionFactory.create();
@@ -318,6 +328,8 @@ Support for the following single-dimensional arrays (read and write):
318328
[psql-txid_snapshot-ref]: https://www.postgresql.org/docs/11/datatype.html
319329
[psql-uuid-ref]: https://www.postgresql.org/docs/11/datatype-uuid.html
320330
[psql-xml-ref]: https://www.postgresql.org/docs/11/datatype-xml.html
331+
[psql-runtime-config]: https://www.postgresql.org/docs/current/runtime-config-client.html
332+
321333

322334

323335
[java-bigdecimal-ref]: https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html

0 commit comments

Comments
 (0)