Package io.vertx.pgclient
Class PgConnectOptions
- java.lang.Object
-
- io.vertx.sqlclient.SqlConnectOptions
-
- io.vertx.pgclient.PgConnectOptions
-
public class PgConnectOptions extends SqlConnectOptions
- Author:
- Julien Viet, Billy Yuan
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_DATABASE
static String
DEFAULT_HOST
static String
DEFAULT_PASSWORD
static int
DEFAULT_PIPELINING_LIMIT
static int
DEFAULT_PORT
static Map<String,String>
DEFAULT_PROPERTIES
static SslMode
DEFAULT_SSLMODE
static boolean
DEFAULT_USE_LAYER_7_PROXY
static String
DEFAULT_USER
-
Fields inherited from class io.vertx.sqlclient.SqlConnectOptions
DEFAULT_CACHE_PREPARED_STATEMENTS, DEFAULT_METRICS_NAME, DEFAULT_PREPARED_STATEMENT_CACHE_FILTER, DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE, DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT, DEFAULT_RECONNECT_ATTEMPTS, DEFAULT_RECONNECT_INTERVAL
-
-
Constructor Summary
Constructors Constructor Description PgConnectOptions()
PgConnectOptions(JsonObject json)
PgConnectOptions(PgConnectOptions other)
PgConnectOptions(SqlConnectOptions other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PgConnectOptions
addProperty(String key, String value)
Add a property for this client, which will be sent to server at the connection start.boolean
equals(Object o)
static PgConnectOptions
fromEnv()
Provide aPgConnectOptions
configured with environment variables, if the environment variable is not set, then a default value will take precedence over this.static PgConnectOptions
fromUri(String connectionUri)
Provide aPgConnectOptions
configured from a connection URI.int
getPipeliningLimit()
SocketAddress
getSocketAddress()
SslMode
getSslMode()
boolean
getUseLayer7Proxy()
int
hashCode()
protected void
init()
Initialize with the default options.boolean
isUsingDomainSocket()
PgConnectOptions
merge(JsonObject other)
Returns new options created after this object and merged with theother
json config.PgConnectOptions
setCachePreparedStatements(boolean cachePreparedStatements)
Set whether prepared statements cache should be enabled.PgConnectOptions
setDatabase(String database)
Specify the default database for the connection.PgConnectOptions
setHost(String host)
Specify the host for connecting to the server.PgConnectOptions
setPassword(String password)
Specify the user password to be used for the authentication.PgConnectOptions
setPipeliningLimit(int pipeliningLimit)
PgConnectOptions
setPort(int port)
Specify the port for connecting to the server.PgConnectOptions
setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)
Set the maximum number of prepared statements that the connection will cache.PgConnectOptions
setPreparedStatementCacheSqlFilter(java.util.function.Predicate<String> predicate)
Set a predicate filtering prepared statements that the connection will cache.PgConnectOptions
setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)
Set the maximum length of prepared statement SQL string that the connection will cache.PgConnectOptions
setProperties(Map<String,String> properties)
Set properties for this client, which will be sent to server at the connection start.PgConnectOptions
setReconnectAttempts(int attempts)
Set the value of reconnect attemptsPgConnectOptions
setReconnectInterval(long interval)
Set the reconnect intervalPgConnectOptions
setSslMode(SslMode sslmode)
SetSslMode
for the client, this option can be used to provide different levels of secure protection.PgConnectOptions
setSslOptions(ClientSSLOptions sslOptions)
PgConnectOptions
setTracingPolicy(TracingPolicy tracingPolicy)
Set the tracing policy for the client behavior when Vert.x has tracing enabled.PgConnectOptions
setUseLayer7Proxy(boolean useLayer7Proxy)
Set the client to use a layer 7 (application) proxy compatible protocol, set totrue
when the client interacts with a layer 7 proxy like PgBouncer instead of a server.PgConnectOptions
setUser(String user)
Specify the user account to be used for the authentication.JsonObject
toJson()
static PgConnectOptions
wrap(SqlConnectOptions options)
-
Methods inherited from class io.vertx.sqlclient.SqlConnectOptions
getCachePreparedStatements, getDatabase, getHost, getMetricsName, getPassword, getPort, getPreparedStatementCacheMaxSize, getPreparedStatementCacheSqlFilter, getProperties, getReconnectAttempts, getReconnectInterval, getSslOptions, getTracingPolicy, getUser, setMetricsName
-
-
-
-
Field Detail
-
DEFAULT_HOST
public static final String DEFAULT_HOST
- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static int DEFAULT_PORT
-
DEFAULT_DATABASE
public static final String DEFAULT_DATABASE
- See Also:
- Constant Field Values
-
DEFAULT_USER
public static final String DEFAULT_USER
- See Also:
- Constant Field Values
-
DEFAULT_PASSWORD
public static final String DEFAULT_PASSWORD
- See Also:
- Constant Field Values
-
DEFAULT_PIPELINING_LIMIT
public static final int DEFAULT_PIPELINING_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_SSLMODE
public static final SslMode DEFAULT_SSLMODE
-
DEFAULT_USE_LAYER_7_PROXY
public static final boolean DEFAULT_USE_LAYER_7_PROXY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PgConnectOptions
public PgConnectOptions()
-
PgConnectOptions
public PgConnectOptions(JsonObject json)
-
PgConnectOptions
public PgConnectOptions(SqlConnectOptions other)
-
PgConnectOptions
public PgConnectOptions(PgConnectOptions other)
-
-
Method Detail
-
wrap
public static PgConnectOptions wrap(SqlConnectOptions options)
- Returns:
- the
options
as PostgreSQL specific connect options
-
fromUri
public static PgConnectOptions fromUri(String connectionUri) throws IllegalArgumentException
Provide aPgConnectOptions
configured from a connection URI.- Parameters:
connectionUri
- the connection URI to configure from- Returns:
- a
PgConnectOptions
parsed from the connection URI - Throws:
IllegalArgumentException
- when theconnectionUri
is in an invalid format
-
fromEnv
public static PgConnectOptions fromEnv()
Provide aPgConnectOptions
configured with environment variables, if the environment variable is not set, then a default value will take precedence over this.
-
setHost
public PgConnectOptions setHost(String host)
Description copied from class:SqlConnectOptions
Specify the host for connecting to the server.- Overrides:
setHost
in classSqlConnectOptions
- Parameters:
host
- the host to specify- Returns:
- a reference to this, so the API can be used fluently
-
setPort
public PgConnectOptions setPort(int port)
Description copied from class:SqlConnectOptions
Specify the port for connecting to the server.- Overrides:
setPort
in classSqlConnectOptions
- Parameters:
port
- the port to specify- Returns:
- a reference to this, so the API can be used fluently
-
setUser
public PgConnectOptions setUser(String user)
Description copied from class:SqlConnectOptions
Specify the user account to be used for the authentication.- Overrides:
setUser
in classSqlConnectOptions
- Parameters:
user
- the user to specify- Returns:
- a reference to this, so the API can be used fluently
-
setPassword
public PgConnectOptions setPassword(String password)
Description copied from class:SqlConnectOptions
Specify the user password to be used for the authentication.- Overrides:
setPassword
in classSqlConnectOptions
- Parameters:
password
- the password to specify- Returns:
- a reference to this, so the API can be used fluently
-
setDatabase
public PgConnectOptions setDatabase(String database)
Description copied from class:SqlConnectOptions
Specify the default database for the connection.- Overrides:
setDatabase
in classSqlConnectOptions
- Parameters:
database
- the database name to specify- Returns:
- a reference to this, so the API can be used fluently
-
getPipeliningLimit
public int getPipeliningLimit()
-
setPipeliningLimit
public PgConnectOptions setPipeliningLimit(int pipeliningLimit)
-
setCachePreparedStatements
public PgConnectOptions setCachePreparedStatements(boolean cachePreparedStatements)
Description copied from class:SqlConnectOptions
Set whether prepared statements cache should be enabled.- Overrides:
setCachePreparedStatements
in classSqlConnectOptions
- Parameters:
cachePreparedStatements
- true if cache should be enabled- Returns:
- a reference to this, so the API can be used fluently
-
setPreparedStatementCacheMaxSize
public PgConnectOptions setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)
Description copied from class:SqlConnectOptions
Set the maximum number of prepared statements that the connection will cache.- Overrides:
setPreparedStatementCacheMaxSize
in classSqlConnectOptions
- Parameters:
preparedStatementCacheMaxSize
- the size to set- Returns:
- a reference to this, so the API can be used fluently
-
setPreparedStatementCacheSqlFilter
public PgConnectOptions setPreparedStatementCacheSqlFilter(java.util.function.Predicate<String> predicate)
Description copied from class:SqlConnectOptions
Set a predicate filtering prepared statements that the connection will cache.The default predicate accepts predicate having query length <
SqlConnectOptions.DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT
- Overrides:
setPreparedStatementCacheSqlFilter
in classSqlConnectOptions
- Parameters:
predicate
- the filter
-
setPreparedStatementCacheSqlLimit
public PgConnectOptions setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)
Description copied from class:SqlConnectOptions
Set the maximum length of prepared statement SQL string that the connection will cache.This is an helper setting the
SqlConnectOptions.setPreparedStatementCacheSqlFilter(Predicate)
.- Overrides:
setPreparedStatementCacheSqlLimit
in classSqlConnectOptions
- Parameters:
preparedStatementCacheSqlLimit
- the maximum length limit of SQL string to set- Returns:
- a reference to this, so the API can be used fluently
-
setProperties
public PgConnectOptions setProperties(Map<String,String> properties)
Description copied from class:SqlConnectOptions
Set properties for this client, which will be sent to server at the connection start.- Overrides:
setProperties
in classSqlConnectOptions
- Parameters:
properties
- the value of properties to specify- Returns:
- a reference to this, so the API can be used fluently
-
addProperty
public PgConnectOptions addProperty(String key, String value)
Description copied from class:SqlConnectOptions
Add a property for this client, which will be sent to server at the connection start.- Overrides:
addProperty
in classSqlConnectOptions
- Parameters:
key
- the value of property keyvalue
- the value of property value- Returns:
- a reference to this, so the API can be used fluently
-
getSslMode
public SslMode getSslMode()
- Returns:
- the value of current sslmode
-
setSslMode
public PgConnectOptions setSslMode(SslMode sslmode)
SetSslMode
for the client, this option can be used to provide different levels of secure protection.- Parameters:
sslmode
- the value of sslmode- Returns:
- a reference to this, so the API can be used fluently
-
getUseLayer7Proxy
@Unstable public boolean getUseLayer7Proxy()
- Returns:
- whether the client interacts with a layer 7 proxy instead of a server
-
setUseLayer7Proxy
@Unstable public PgConnectOptions setUseLayer7Proxy(boolean useLayer7Proxy)
Set the client to use a layer 7 (application) proxy compatible protocol, set totrue
when the client interacts with a layer 7 proxy like PgBouncer instead of a server. Prepared statement caching must be disabled.- Parameters:
useLayer7Proxy
- whether to use a layer 7 proxy instead of a server- Returns:
- a reference to this, so the API can be used fluently
-
setReconnectAttempts
public PgConnectOptions setReconnectAttempts(int attempts)
Description copied from class:SqlConnectOptions
Set the value of reconnect attempts- Overrides:
setReconnectAttempts
in classSqlConnectOptions
- Parameters:
attempts
- the maximum number of reconnect attempts- Returns:
- a reference to this, so the API can be used fluently
-
setReconnectInterval
public PgConnectOptions setReconnectInterval(long interval)
Description copied from class:SqlConnectOptions
Set the reconnect interval- Overrides:
setReconnectInterval
in classSqlConnectOptions
- Parameters:
interval
- the reconnect interval in ms- Returns:
- a reference to this, so the API can be used fluently
-
setTracingPolicy
public PgConnectOptions setTracingPolicy(TracingPolicy tracingPolicy)
Description copied from class:SqlConnectOptions
Set the tracing policy for the client behavior when Vert.x has tracing enabled.- Overrides:
setTracingPolicy
in classSqlConnectOptions
- Parameters:
tracingPolicy
- the tracing policy- Returns:
- a reference to this, so the API can be used fluently
-
setSslOptions
public PgConnectOptions setSslOptions(ClientSSLOptions sslOptions)
- Overrides:
setSslOptions
in classSqlConnectOptions
-
init
protected void init()
Initialize with the default options.- Overrides:
init
in classSqlConnectOptions
-
toJson
public JsonObject toJson()
- Overrides:
toJson
in classSqlConnectOptions
-
getSocketAddress
public SocketAddress getSocketAddress()
- Overrides:
getSocketAddress
in classSqlConnectOptions
-
isUsingDomainSocket
public boolean isUsingDomainSocket()
- Overrides:
isUsingDomainSocket
in classSqlConnectOptions
-
merge
public PgConnectOptions merge(JsonObject other)
Description copied from class:SqlConnectOptions
Returns new options created after this object and merged with theother
json config.- Overrides:
merge
in classSqlConnectOptions
- Parameters:
other
- the other JSON object- Returns:
- new options created after this object and merged with the
other
json config
-
-