public static class Connection.Builder
extends java.lang.Object
| Constructor and Description |
|---|
Builder()
Creates an empty builder.
|
Builder(@NotNull Connection.Builder b)
Copies a connection builder.
|
Builder(@NotNull java.net.URI uri)
Parses a db-ul as a builder.
|
| Modifier and Type | Method and Description |
|---|---|
@NotNull Connection.Builder |
authKey(@Nullable java.lang.String authKey)
Deprecated.
Use
user(String, String) instead.
(Will be removed on v2.5.0) |
@NotNull Connection.Builder |
certFile(@NotNull java.util.concurrent.Callable<java.io.InputStream> source)
Sets a certificate to provide SSL encryption to the RethinkDB Connection.
|
@NotNull Connection.Builder |
certFile(@NotNull java.io.File file)
Sets a certificate to provide SSL encryption to the RethinkDB Connection.
|
@NotNull Connection.Builder |
certFile(@NotNull java.io.InputStream source)
Sets a certificate to provide SSL encryption to the RethinkDB Connection.
|
@NotNull Connection |
connect()
Creates a new connection and connects to the server.
|
@NotNull java.util.concurrent.CompletableFuture<Connection> |
connectAsync()
Creates a new connection and connects asynchronously to the server.
|
@NotNull Connection.Builder |
copyOf()
Deprecated.
Use
r.connection(Builder) instead.
(Will be removed on v2.5.0) |
@NotNull Connection.Builder |
db(@Nullable java.lang.String dbname)
Sets a custom database for the connection.
|
@NotNull java.net.URI |
dbUrl()
Creates a
URI with the db-url representing this connection builder. |
@NotNull java.lang.String |
dbUrlString()
Creates a db-url representing this connection builder.
|
@NotNull Connection.Builder |
defaultFetchMode(@Nullable Result.FetchMode defaultFetchMode)
Sets the default fetch mode for sequences.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
@NotNull Connection.Builder |
hostname(@Nullable java.lang.String hostname)
Sets a custom hostname for the connection.
|
@NotNull Connection.Builder |
persistentThreads(boolean enabled)
Sets if the response pump should use daemon threads or not.
Using persistent threads guarantees that the JVM will not exit once the main thread finishes, but will keep the JVM alive if the connection is not closed. Daemon threads will ensure that the JVM can exit automatically, but may or may not ignore ongoing asynchronous queries. |
@NotNull Connection.Builder |
port(@Nullable java.lang.Integer port)
Sets a custom port for the connection.
|
@NotNull Connection.Builder |
pumpFactory(ResponsePump.Factory pumpFactory)
Sets a custom
ResponsePump factory for the connection. |
@NotNull Connection.Builder |
socketFactory(ConnectionSocket.Factory socketFactory)
Sets a custom
ConnectionSocket factory for the connection. |
@NotNull Connection.Builder |
sslContext(@Nullable javax.net.ssl.SSLContext sslContext)
Sets a
SSLContext to provide SSL encryption to the RethinkDB Connection. |
@NotNull Connection.Builder |
timeout(@Nullable java.lang.Long timeout)
Sets a custom timeout for the connection, in milliseconds.
|
java.lang.String |
toString() |
@NotNull Connection.Builder |
unwrapLists(boolean enabled)
Sets list unwrapping behaviour for lists.
|
@NotNull Connection.Builder |
user(@Nullable java.lang.String user)
Sets a custom username for the connection.
|
@NotNull Connection.Builder |
user(@Nullable java.lang.String user,
@Nullable java.lang.String password)
Sets a custom username and password for the connection.
|
public Builder()
public Builder(@NotNull
@NotNull java.net.URI uri)
uri - the db-url to parse.public Builder(@NotNull
@NotNull Connection.Builder b)
b - the original builder.@Deprecated @NotNull public @NotNull Connection.Builder copyOf()
r.connection(Builder) instead.
(Will be removed on v2.5.0)@NotNull public @NotNull Connection.Builder hostname(@Nullable @Nullable java.lang.String hostname)
(Configurable by Db-url)
hostname - the hostname, or null.@NotNull public @NotNull Connection.Builder port(@Nullable @Nullable java.lang.Integer port)
(Configurable by Db-url)
port - the port, or null.@NotNull public @NotNull Connection.Builder user(@Nullable @Nullable java.lang.String user)
(Configurable by Db-url)
user - the username, or null.@NotNull public @NotNull Connection.Builder user(@Nullable @Nullable java.lang.String user, @Nullable @Nullable java.lang.String password)
(Configurable by Db-url)
user - the username, or null.password - the password, or null.@NotNull public @NotNull Connection.Builder db(@Nullable @Nullable java.lang.String dbname)
(Configurable by Db-url)
dbname - the database name, or null.@NotNull public @NotNull Connection.Builder timeout(@Nullable @Nullable java.lang.Long timeout)
(Db-url key: "timeout")
timeout - the timeout, or null.@Deprecated @NotNull public @NotNull Connection.Builder authKey(@Nullable @Nullable java.lang.String authKey)
user(String, String) instead.
(Will be removed on v2.5.0)(No db-url support)
authKey - the authentication key, or null.@NotNull public @NotNull Connection.Builder certFile(@NotNull @NotNull java.util.concurrent.Callable<java.io.InputStream> source)
(No db-url support)
source - a callable which provides a InputStream with the contents of a certificate file.@NotNull public @NotNull Connection.Builder certFile(@NotNull @NotNull java.io.InputStream source)
(No db-url support)
source - a InputStream with the contents of a certificate file.@NotNull public @NotNull Connection.Builder certFile(@NotNull @NotNull java.io.File file)
(No db-url support)
file - a certificate file to read from.@NotNull public @NotNull Connection.Builder sslContext(@Nullable @Nullable javax.net.ssl.SSLContext sslContext)
SSLContext to provide SSL encryption to the RethinkDB Connection.
(No db-url support)
sslContext - the SSL context, or null.@NotNull public @NotNull Connection.Builder socketFactory(@Nullable ConnectionSocket.Factory socketFactory)
ConnectionSocket factory for the connection.
(Java Driver-specific, No db-url support)
socketFactory - the connection socket factory, or null.@NotNull public @NotNull Connection.Builder pumpFactory(@Nullable ResponsePump.Factory pumpFactory)
ResponsePump factory for the connection.
(Java Driver-specific, No db-url support)
pumpFactory - the response pump factory, or null.@NotNull public @NotNull Connection.Builder defaultFetchMode(@Nullable @Nullable Result.FetchMode defaultFetchMode)
Fetch mode is a Java-driver specific behaviour that allows for fine-tuning on partial sequence fetching.Can be used to balance between high availability and network optimization. The aggressive fetch mode will make best effort to consume the entire sequence, as fast as possible, to ensure high availability to the consumer, while the lazy fetch mode will make no effort and await until all objects were consumed before fetching the next one.
In addiction, there are many preemptive fetch modes, which will consume the next sequence once the buffer reaches half, a third, a fourth, a fitfh, a sixth, a seventh or an eighth of it's capacity.
(Java Driver-specific, Db-url key: "java.default_fetch_mode")
defaultFetchMode - a default fetch mode, or null.@NotNull public @NotNull Connection.Builder unwrapLists(boolean enabled)
List unwrapping is a Java-driver specific behaviour that unwraps an atom response from the server, which is a list, as if it were a sequence of objects.Consider the following:
r.expr(r.array("a", "b", "c")).run(conn);By default, it returns a
Resultwith a singleList["a","b","c"] inside.With list unwrapping, it returns a
Resultwith "a", "b", "c" inside.The feature makes the code a bit less verbose. For example, iterating goes from:
((List<String>)result.single()).forEach(s -> ...)To:
(Java Driver-specific, Db-url key: "java.unwrap_lists")
enabled - true to enable list unwrapping, false to disable.@NotNull public @NotNull Connection.Builder persistentThreads(boolean enabled)
Using persistent threads guarantees that the JVM will not exit once the main thread finishes, but will keep the JVM alive if the connection is not closed.
Daemon threads will ensure that the JVM can exit automatically, but may or may not ignore ongoing asynchronous queries. Your milage may vary. (HTTP or other application frameworks may open persistent threads by themselves and may keep the JVM alive until the main window or application shuts down.)
(Java Driver-specific, Db-url key: "java.default_fetch_mode")
enabled - true to use persistent threads in the response pump, false to use daemon threads.Thread.setDaemon(boolean)@NotNull public @NotNull java.util.concurrent.CompletableFuture<Connection> connectAsync()
CompletableFuture which completes with the connection once connected.@NotNull public @NotNull Connection connect()
@NotNull public @NotNull java.net.URI dbUrl()
URI with the db-url representing this connection builder.URI.@NotNull public @NotNull java.lang.String dbUrlString()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object