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
:
...
Encode Request
var encodeRequest = EncodeRequest.builder()
.addHost(ConnectionInfo.builder().port(8125).build()id("123")
.withReadTimeout(Duration.ofSeconds(5))
.withConnectionPool(5, Duration.ofMinutes(30))chunk("First chunk of text for the encoding")
.withObjectMapperchunk(new ObjectMapper())
.withBackoffPolicy(BackoffPolicyProperties.builder().retries(10).build()"Second chunk of text for the prediction")
.meterRegistrybuild(meterRegistry);
var result = client.buildencode(request)) ;
The result
will return 200
for the status code and the corresponding list of vectors:
{
"id": 123,
// Do something with the client
}
...
"results": [[float-list], [float-list]],
"status": 200
}