Configuration
Example configuration in a yaml:
servers:
- localhost:8125
connection:
connectTimeout: 5s
readTimeout: 10s
pool:
size: 10
keepAlive: 1m
backoffPolicy:
type: EXPONENTIAL
initialDelay: 5s
retries: 2
Configuration parameters
servers
(Required, List) A list of strings (or ConnectionInfo
objects) with the location to the BERT service
connection.connectTimeout
(Optional, String. Default: 60s
) The duration for the connection timeout
connection.readTimeout
(Optional, String. Default: 60s
) The duration for the read timeout
connection.pool.size
(Optional, Integer, Default: 5
) The size of the connection pool
connection.pool.keepAlive
(Optional, String, Default: 5m
) The duration of the connection in the pool
backoffPolicy.type
(Optional, String. Default: EXPONENTIAL
) The backoff policy for retries: NONE
, CONSTANT
, EXPONENTIAL
backoffPolicy.initialDelay
(Optional, String. Default: 50ms
) The initial delay before the first retry
backoffPolicy.retries
(Optional, Integer. Default: 2
) The number of retries
Initialization
Example initialization of the BERTRestClient
:
@Inject
MeterRegistry meterregistry;
try (var client = BERTRestClient.builder()
.addHost(ConnectionInfo.builder().port(8125).build())
.withReadTimeout(Duration.ofSeconds(5))
.withConnectionPool(5, Duration.ofMinutes(30))
.withObjectMapper(new ObjectMapper())
.withBackoffPolicy(BackoffPolicyProperties.builder().retries(10).build())
.meterRegistry(meterRegistry)
.build()) {
// Do something with the client
}
Note that in extension to the properties described in the previous section, a custom ObjectMapper
can be used for the serialization/deserialization of JSON data.