Package io.oxia.client.api
Interface OxiaClientBuilder
public interface OxiaClientBuilder
Builder for
SyncOxiaClient and AsyncOxiaClient.-
Method Summary
Modifier and TypeMethodDescriptionCreate an asynchronous client.authentication(Authentication authentication) Configure the authentication plugin and its parameters.authentication(String authPluginClassName, String authParamsString) Configure the authentication plugin and its parameters.batchLinger(Duration batchLinger) Specify the maximum time to wait for a batch to be sent.clientIdentifier(String clientIdentifier) Specify the client identifier for this client instance.clientIdentifier(Supplier<String> clientIdentifier) Specify the client identifier for this client instance.connectionBackoff(Duration minDelay, Duration maxDelay) Configure the connection backoff policy.connectionKeepAliveTime(Duration connectionKeepAlive) Configure the keep alive interval for the connection.connectionKeepAliveTimeout(Duration connectionKeepAliveTimeout) Configure the keep alive timeout for the connection.static OxiaClientBuilderCreate a new client builder.enableTls(boolean enableTls) Configures whether to enable TLS (Transport Layer Security) for the client connection.loadConfig(File configFile) Load the configuration from the specified configuration file.loadConfig(String configPath) Load the configuration from the specified configuration file.loadConfig(Properties properties) Load the configuration from the specified properties.maxConnectionPerNode(int connections) Configure the maximum number of connections to each Oxia server node.maxRequestsPerBatch(int maxRequestsPerBatch) Specify the maximum number of requests to include in a batch.Specify the Oxia namesace to use for this client instance.openTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Specify the OpenTelemetry instance to use for this client instance.requestTimeout(Duration requestTimeout) Specify a custom timeout for all requests.sessionTimeout(Duration sessionTimeout) Specify the session timeout for this client instance.Create a synchronous client.
-
Method Details
-
create
Create a new client builder.- Parameters:
serviceAddress- the address of the Oxia server- Returns:
- the client builder instance
-
syncClient
Create a synchronous client.This method is blocking while the client initializes and talks to the server.
- Returns:
- the synchronous client instance
- Throws:
OxiaException- if failed to create the client
-
asyncClient
CompletableFuture<AsyncOxiaClient> asyncClient()Create an asynchronous client.- Returns:
- a future to retrieve the client instance, when ready
-
requestTimeout
Specify a custom timeout for all requests.Default is
30 secs.- Parameters:
requestTimeout- the timeout duration- Returns:
- the builder instance
-
batchLinger
Specify the maximum time to wait for a batch to be sent.Default is
5 millisA larger linger time might help in creating batches with more ops in them and thus might improve the overall throughput.
A shorter linger time might help in minimizing the latency.
- Parameters:
batchLinger- the batch linger duration- Returns:
- the builder instance
-
maxRequestsPerBatch
Specify the maximum number of requests to include in a batch.Default is
1000.- Parameters:
maxRequestsPerBatch- the maximum number of requests per batch- Returns:
- the builder instance
-
namespace
Specify the Oxia namesace to use for this client instance.Default is
"default".- Parameters:
namespace- the namespace to use- Returns:
- the builder instance
-
sessionTimeout
Specify the session timeout for this client instance.Default is
30 secs.- Parameters:
sessionTimeout- the session timeout duration- Returns:
- the builder instance
- See Also:
-
clientIdentifier
Specify the client identifier for this client instance.Default is a random UUID.
- Parameters:
clientIdentifier- the client identifier- Returns:
- the builder instance
- See Also:
-
clientIdentifier
Specify the client identifier for this client instance.Default is a random UUID.
- Parameters:
clientIdentifier- the client identifier supplier- Returns:
- the builder instance
- See Also:
-
openTelemetry
Specify the OpenTelemetry instance to use for this client instance.By default, the client will use the global OpenTelemetry instance if available.
- Parameters:
openTelemetry- an OpenTelemetry instance- Returns:
- the builder instance
-
authentication
Configure the authentication plugin and its parameters.- Parameters:
authentication- the authentication instance- Returns:
- the builder instance
-
connectionBackoff
Configure the connection backoff policy.Defaults are
min=100millis, max=30sec.- Parameters:
minDelay- the minimum delay between retriesmaxDelay- the maximum delay between retries- Returns:
- the builder instance
-
maxConnectionPerNode
Configure the maximum number of connections to each Oxia server node.Default is
1.- Parameters:
connections- the maximum number of connections- Returns:
- the builder instance
-
connectionKeepAliveTimeout
Configure the keep alive timeout for the connection.Default is
5 sec.- Parameters:
connectionKeepAliveTimeout- the keep alive timeout duration- Returns:
- the builder instance
-
connectionKeepAliveTime
Configure the keep alive interval for the connection.Default is
10 sec.- Parameters:
connectionKeepAlive- the keep alive interval duration- Returns:
- the builder instance
-
authentication
OxiaClientBuilder authentication(String authPluginClassName, String authParamsString) throws UnsupportedAuthenticationException Configure the authentication plugin and its parameters.- Parameters:
authPluginClassName- the class name of the authentication pluginauthParamsString- the parameters of the authentication plugin- Returns:
- the OxiaClientBuilder instance
- Throws:
UnsupportedAuthenticationException- if the authentication plugin is not supported
-
enableTls
Configures whether to enable TLS (Transport Layer Security) for the client connection.- Parameters:
enableTls- true to enable TLS, false to disable it- Returns:
- the builder instance for method chaining
-
loadConfig
Load the configuration from the specified configuration file.- Parameters:
configPath- the path of the configuration file- Returns:
- the OxiaClientBuilder instance
-
loadConfig
Load the configuration from the specified configuration file.- Parameters:
configFile- the configuration file- Returns:
- the OxiaClientBuilder instance
-
loadConfig
Load the configuration from the specified properties.- Parameters:
properties- the properties- Returns:
- the OxiaClientBuilder instance
-