Package ai.vespa.feed.client
Class FeedClientBuilder
- java.lang.Object
-
- ai.vespa.feed.client.FeedClientBuilder
-
public class FeedClientBuilder extends Object
Builder for creating aFeedClient
instance.- Author:
- bjorncs, jonmv
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FeedClientBuilder
addRequestHeader(String name, String value)
Adds HTTP request header to all client requests.FeedClientBuilder
addRequestHeader(String name, Supplier<String> valueSupplier)
Adds HTTP request header to all client requests.FeedClient
build()
Constructs instance ofFeedClient
from builder configurationstatic FeedClientBuilder
create(URI endpoint)
Creates a builder for a single container endpointstatic FeedClientBuilder
create(List<URI> endpoints)
Creates a builder for multiple container endpointsFeedClientBuilder
noBenchmarking()
Turns off benchmarking.FeedClientBuilder
setCaCertificates(Collection<X509Certificate> caCertificates)
Overrides JVM default SSL truststoreFeedClientBuilder
setCaCertificatesFile(Path caCertificatesFile)
Overrides JVM default SSL truststoreFeedClientBuilder
setCertificate(Path certificatePemFile, Path privateKeyPemFile)
Sets path to client SSL certificate/key PEM filesFeedClientBuilder
setCertificate(X509Certificate certificate, PrivateKey privateKey)
Sets client SSL certificate/keyFeedClientBuilder
setCertificate(Collection<X509Certificate> certificate, PrivateKey privateKey)
Sets client SSL certificates/keyFeedClientBuilder
setCircuitBreaker(FeedClient.CircuitBreaker breaker)
Overrides default circuit breaker.FeedClientBuilder
setConnectionsPerEndpoint(int max)
Sets the number of connections this client will use per endpoint.FeedClientBuilder
setDryrun(boolean enabled)
FeedClientBuilder
setHostnameVerifier(HostnameVerifier verifier)
SetsHostnameVerifier
instance (e.g for disabling default SSL hostname verification).FeedClientBuilder
setMaxStreamPerConnection(int max)
Sets the maximum number of streams per HTTP/2 connection for this client.FeedClientBuilder
setRetryStrategy(FeedClient.RetryStrategy strategy)
Overrides default retry strategy.FeedClientBuilder
setSslContext(SSLContext context)
SetsSSLContext
instance.
-
-
-
Method Detail
-
create
public static FeedClientBuilder create(URI endpoint)
Creates a builder for a single container endpoint
-
create
public static FeedClientBuilder create(List<URI> endpoints)
Creates a builder for multiple container endpoints
-
setConnectionsPerEndpoint
public FeedClientBuilder setConnectionsPerEndpoint(int max)
Sets the number of connections this client will use per endpoint. A reasonable value here is a value that lets all feed clients (if more than one) collectively have a number of connections which is a small multiple of the numbers of containers in the cluster to feed, so load can be balanced across these containers. In general, this value should be kept as low as possible, but poor connectivity between feeder and cluster may also warrant a higher number of connections.
-
setMaxStreamPerConnection
public FeedClientBuilder setMaxStreamPerConnection(int max)
Sets the maximum number of streams per HTTP/2 connection for this client. This determines the maximum number of concurrent, inflight requests for this client, which ismaxConnections * maxStreamsPerConnection
. Prefer more streams over more connections, when possible. The feed client automatically throttles load to achieve the best throughput, and the actual number of streams per connection is usually lower than the maximum.
-
setSslContext
public FeedClientBuilder setSslContext(SSLContext context)
SetsSSLContext
instance.
-
setHostnameVerifier
public FeedClientBuilder setHostnameVerifier(HostnameVerifier verifier)
SetsHostnameVerifier
instance (e.g for disabling default SSL hostname verification).
-
noBenchmarking
public FeedClientBuilder noBenchmarking()
Turns off benchmarking. Attempting to getFeedClient.stats()
will result in an exception.
-
addRequestHeader
public FeedClientBuilder addRequestHeader(String name, String value)
Adds HTTP request header to all client requests.
-
addRequestHeader
public FeedClientBuilder addRequestHeader(String name, Supplier<String> valueSupplier)
Adds HTTP request header to all client requests. ValueSupplier
is invoked for each HTTP request, i.e. value can be dynamically updated during a feed.
-
setRetryStrategy
public FeedClientBuilder setRetryStrategy(FeedClient.RetryStrategy strategy)
Overrides default retry strategy.- See Also:
FeedClient.RetryStrategy
-
setCircuitBreaker
public FeedClientBuilder setCircuitBreaker(FeedClient.CircuitBreaker breaker)
Overrides default circuit breaker.- See Also:
FeedClient.CircuitBreaker
-
setCertificate
public FeedClientBuilder setCertificate(Path certificatePemFile, Path privateKeyPemFile)
Sets path to client SSL certificate/key PEM files
-
setCertificate
public FeedClientBuilder setCertificate(Collection<X509Certificate> certificate, PrivateKey privateKey)
Sets client SSL certificates/key
-
setCertificate
public FeedClientBuilder setCertificate(X509Certificate certificate, PrivateKey privateKey)
Sets client SSL certificate/key
-
setDryrun
public FeedClientBuilder setDryrun(boolean enabled)
-
setCaCertificatesFile
public FeedClientBuilder setCaCertificatesFile(Path caCertificatesFile)
Overrides JVM default SSL truststore- Parameters:
caCertificatesFile
- Path to PEM encoded file containing trusted certificates
-
setCaCertificates
public FeedClientBuilder setCaCertificates(Collection<X509Certificate> caCertificates)
Overrides JVM default SSL truststore
-
build
public FeedClient build()
Constructs instance ofFeedClient
from builder configuration
-
-