Client Configuration
Configuring the CRUD Client
Currently, TarantoolCrudClient configuration can be done through:
- Java classes (JavaConfig);
- Java classes (JavaConfig) without using the
@EnableTarantoolRepositoriesannotation; - Configuration files (.properties/.yaml).
Configuration via Java Classes
To configure a client for working with Spring Data Tarantool, you need to create a class with
@Configuration and @EnableTarantoolRepositories annotations. In this class, you need to create a factory
method with the @Bean annotation that returns an instance of TarantoolCrudClientBuilder with all
necessary settings:
import io.tarantool.client.factory.TarantoolCrudClientBuilder;
import io.tarantool.client.factory.TarantoolFactory;
import io.tarantool.spring.data.repository.config.EnableTarantoolRepositories;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableTarantoolRepositories
public class Config {
@Bean
public TarantoolCrudClientBuilder clientSettings() {
return TarantoolFactory.crud()
.withHost("localhost")
.withPort(3301)
.withPassword("secret-cluster-cookie");
}
}
Important!
The full list of parameters and their purposes can be found in the javadoc for
TarantoolCrudClientBuilder
Client Configuration via Configuration File
To configure the client through a configuration file (for example, via
application.properties or application.yaml), you need to use the following parameters:
spring:
data:
tarantool:
host: localhost #(1)!
port: 3301 #(2)!
user-name: user #(3)!
password: password #(4)!
graceful-shutdown-enabled: true #(5)!
balancer-mode: distributing_round_robin #(6)!
connect-timeout: 5000 #(7)!
reconnect-after: 1000 #(8)!
connection-groups: #(9)!
- auth-type: pap_sha256 #(10)!
host: localhost #(11)!
port: 3301 #(12)!
user-name: "user" #(13)!
password: secret #(14)!
connection-group-size: 4 #(15)!
tag: first-router #(16)!
flush-consolidation-handler: #(17)!
explicit-flush-after-flushes: 256
consolidate-when-no-read-in-progress: false
- host: localhost
port: 3302
user-name: "user"
password: secret
connection-group-size: 2
tag: second-router
event-loop-threads-count: 10 #(18)!
heartbeat: #(19)!
death-threshold: 4
invalidation-threshold: 2
ping-interval: 56
window-size: 12
- The address to which the client connects
- The port to which the client connects on
host - The username for connecting to
Tarantool - The password for connecting to
Tarantool - Whether to use the
graceful shutdownprotocol - Selection of the request balancing type
- Timeout for connecting to
Tarantoolin ms (connect-timeout: 5000- 5 seconds) - Time in ms after which to reconnect upon failed connection
(
reconnect-after: 1000- 1 second) - Sets a list of connection groups with descriptions of each
- Authentication protocol type
- The address to which the client connects
- The port to which the client connects on
host - The username for connecting to
Tarantool - The password for connecting to
Tarantool - Number of connections in one group
- Tag, group name
- Allows configuring
flushnetty parameters - Number of threads allocated to netty
- Settings for pinging nodes
Tarantool
Important
- When specifying at least one element of the
connection-groupsgroup, the parameters
spring.data.tarantool.host,spring.data.tarantool.port,spring.data.tarantool.user-name,spring.data.tarantool.password,spring.data.tarantool.connection-group-size,spring.data.tarantool.tagare ignored - In each group, these parameters (
spring.data.tarantool.host,spring.data.tarantool.connection-groups.[*].port,spring.data.tarantool.connection-groups.[*].user-name,spring.data.tarantool.connection-groups.[*].password, ...) are set individually.
Note
More information about parameters:
- Information about
heartbeatparameters can be found in the javadoc for Heartbeat - Official Netty documentation about
flush-consolidation-handler
Important
The capabilities of client configuration through configuration files are limited compared to configuration through Java classes, as some parameters are not available.
Full list of unavailable features:
- Defining Netty channel parameters;
- Defining Watchers parameters;
- Defining handler for packets that were ignored;
- Defining SSL parameters;
- Setting a custom TimerService;
- Setting a custom Micrometer metrics registry.
Important
When using client settings through configuration files and Java classes simultaneously, the configuration based on Java classes will be selected.
When starting the Spring context with @EnableTarantoolRepositories, the following actions will be performed:
- connecting the client to the
Tarantoolcluster based on the parameters specified inTarantoolCrudClientBuilder; - registering user
Repositoryin the Spring context; - registering the
TarantoolCrudClientcomponent in the Spring context.
Configuration via Java Classes (JavaConfig) without using @EnableTarantoolRepositories
You can use the TarantoolCrudClient API directly by registering the component in the Spring
context:
import io.tarantool.client.factory.TarantoolFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Config {
@Bean
public TarantoolCrudClient crudClient() {
return TarantoolFactory.crud()
.withHost("localhost")
.withPort(3301)
.withPassword("secret-cluster-cookie")
.build();
}
}
Important
In this case, working with the cluster is only done through the TarantoolCrudClient API
Configuring the BOX Client
Currently, box client configuration can only be done through Java classes (JavaConfig)
without using the @EnableTarantoolRepositories annotation:
import io.tarantool.client.factory.TarantoolFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Config {
@Bean
public TarantoolBoxClient boxClient() {
return TarantoolFactory.box()
.withHost("localhost")
.withPort(3301)
.withUser("guest")
.build();
}
}