Package io.etcd.jetcd
Class ClientBuilder
- java.lang.Object
-
- io.etcd.jetcd.ClientBuilder
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class ClientBuilder extends java.lang.Object implements java.lang.CloneableClientBuilder knows how to create an Client instance.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientBuilderauthHeader(java.lang.String key, java.lang.String value)Add an auth header.java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object>authHeaders()Returns the headers to be added to auth request headersClientBuilderauthHeaders(java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object> authHeaders)Set the auth headers.java.util.List<io.grpc.ClientInterceptor>authInterceptors()Returns the auth interceptorsClientBuilderauthInterceptors(io.grpc.ClientInterceptor interceptor, io.grpc.ClientInterceptor... interceptors)Add an auth interceptor.ClientBuilderauthInterceptors(java.util.List<io.grpc.ClientInterceptor> interceptors)Set the auth interceptors.java.lang.Stringauthority()Returns The authority used to authenticate connections to servers.ClientBuilderauthority(java.lang.String authority)Sets the authority used to authenticate connections to servers.Clientbuild()build a new Client.java.time.DurationconnectTimeout()Returns the connect timeout.ClientBuilderconnectTimeout(java.time.Duration connectTimeout)Set the connection timeout.ClientBuildercopy()Returns a copy of this builderClientBuilderendpoints(java.lang.Iterable<java.net.URI> endpoints)configure etcd server endpoints using theIPNameResolver.ClientBuilderendpoints(java.lang.String... endpoints)configure etcd server endpoints using theIPNameResolver.ClientBuilderendpoints(java.net.URI... endpoints)configure etcd server endpoints using theIPNameResolver.java.util.concurrent.ExecutorServiceexecutorService()Returns the executor serviceClientBuilderexecutorService(java.util.concurrent.ExecutorService executorService)config executor service.ClientBuilderheader(java.lang.String key, java.lang.String value)Set headers.java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object>headers()Returns the headers to be added to http request headersClientBuilderheaders(java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object> headers)Sets headers to be added to http request headers.ClientBuilderinterceptor(io.grpc.ClientInterceptor interceptor, io.grpc.ClientInterceptor... interceptors)Add an interceptor.java.util.List<io.grpc.ClientInterceptor>interceptors()Returns the interceptorsClientBuilderinterceptors(java.util.List<io.grpc.ClientInterceptor> interceptors)Set the interceptors.java.time.DurationkeepaliveTime()ClientBuilderkeepaliveTime(java.time.Duration keepaliveTime)The interval for gRPC keepalives.java.time.DurationkeepaliveTimeout()ClientBuilderkeepaliveTimeout(java.time.Duration keepaliveTimeout)The timeout for gRPC keepalivesjava.lang.BooleankeepaliveWithoutCalls()ClientBuilderkeepaliveWithoutCalls(java.lang.Boolean keepaliveWithoutCalls)Keepalive option for gRPCjava.lang.StringloadBalancerPolicy()get the load balancer policy for etcd client.ClientBuilderloadBalancerPolicy(java.lang.String loadBalancerPolicy)config load balancer policy.java.lang.IntegermaxInboundMessageSize()Returns the maximum message size allowed for a single gRPC frame.ClientBuildermaxInboundMessageSize(java.lang.Integer maxInboundMessageSize)Sets the maximum message size allowed for a single gRPC frame.ByteSequencenamespace()Returns the namespace of each key usedClientBuildernamespace(ByteSequence namespace)config the namespace of keys used inKV,Txn,LockandWatch.ByteSequencepassword()Returns the auth passwordClientBuilderpassword(ByteSequence password)config etcd auth password.java.time.temporal.ChronoUnitretryChronoUnit()Returns he retries period unit.ClientBuilderretryChronoUnit(java.time.temporal.ChronoUnit retryChronoUnit)Sets the retries period unit.longretryDelay()Returns The delay between retries.ClientBuilderretryDelay(long retryDelay)The delay between retries.longretryMaxDelay()Returns the max backing off delay between retriesClientBuilderretryMaxDelay(long retryMaxDelay)Set the max backing off delay between retries.java.time.DurationretryMaxDuration()Returns the retries max duration.ClientBuilderretryMaxDuration(java.time.Duration retryMaxDuration)Set the retries max duration.io.netty.handler.ssl.SslContextsslContext()Returns the ssl contextClientBuildersslContext(io.netty.handler.ssl.SslContext sslContext)SSL/TLS context to use instead of the system default.ClientBuildersslContext(java.util.function.Consumer<io.netty.handler.ssl.SslContextBuilder> consumer)Configure SSL/TLS context create throughGrpcSslContexts.forClient()to use.java.lang.Stringtarget()Gets the etcd target.ClientBuildertarget(java.lang.String target)configure etcd server endpoints.ByteSequenceuser()Returns the auth userClientBuilderuser(ByteSequence user)config etcd auth user.booleanwaitForReady()Enable gRPC's wait for ready semantics.ClientBuilderwaitForReady(boolean waitForReady)Configure the gRPC's wait for ready semantics.
-
-
-
Method Detail
-
target
public java.lang.String target()
Gets the etcd target.- Returns:
- the etcd target.
-
target
public ClientBuilder target(java.lang.String target)
configure etcd server endpoints.- Parameters:
target- etcd server target- Returns:
- this builder to train
- Throws:
java.lang.NullPointerException- if target is null or one of endpoint is null
-
endpoints
public ClientBuilder endpoints(java.lang.String... endpoints)
configure etcd server endpoints using theIPNameResolver.- Parameters:
endpoints- etcd server endpoints, at least one- Returns:
- this builder to train
- Throws:
java.lang.NullPointerException- if endpoints is null or one of endpoint is nulljava.lang.IllegalArgumentException- if some endpoint is invalid
-
endpoints
public ClientBuilder endpoints(java.net.URI... endpoints)
configure etcd server endpoints using theIPNameResolver.- Parameters:
endpoints- etcd server endpoints, at least one- Returns:
- this builder to train
- Throws:
java.lang.NullPointerException- if endpoints is null or one of endpoint is nulljava.lang.IllegalArgumentException- if some endpoint is invalid
-
endpoints
public ClientBuilder endpoints(java.lang.Iterable<java.net.URI> endpoints)
configure etcd server endpoints using theIPNameResolver.- Parameters:
endpoints- etcd server endpoints, at least one- Returns:
- this builder to train
- Throws:
java.lang.NullPointerException- if endpoints is null or one of endpoint is nulljava.lang.IllegalArgumentException- if some endpoint is invalid
-
user
public ByteSequence user()
Returns the auth user
-
user
public ClientBuilder user(ByteSequence user)
config etcd auth user.- Parameters:
user- etcd auth user- Returns:
- this builder
- Throws:
java.lang.NullPointerException- if user isnull
-
password
public ByteSequence password()
Returns the auth password
-
password
public ClientBuilder password(ByteSequence password)
config etcd auth password.- Parameters:
password- etcd auth password- Returns:
- this builder
- Throws:
java.lang.NullPointerException- if password isnull
-
namespace
public ByteSequence namespace()
Returns the namespace of each key used
-
namespace
public ClientBuilder namespace(ByteSequence namespace)
config the namespace of keys used inKV,Txn,LockandWatch. "/" will be treated as no namespace.- Parameters:
namespace- the namespace of each key used- Returns:
- this builder
- Throws:
java.lang.NullPointerException- if namespace isnull
-
executorService
public java.util.concurrent.ExecutorService executorService()
Returns the executor service
-
executorService
public ClientBuilder executorService(java.util.concurrent.ExecutorService executorService)
config executor service.- Parameters:
executorService- executor service- Returns:
- this builder
- Throws:
java.lang.NullPointerException- if executorService isnull
-
loadBalancerPolicy
public ClientBuilder loadBalancerPolicy(java.lang.String loadBalancerPolicy)
config load balancer policy.- Parameters:
loadBalancerPolicy- etcd load balancer policy- Returns:
- this builder
- Throws:
java.lang.NullPointerException- if loadBalancerPolicy isnull
-
loadBalancerPolicy
public java.lang.String loadBalancerPolicy()
get the load balancer policy for etcd client.- Returns:
- loadBalancerFactory
-
sslContext
public io.netty.handler.ssl.SslContext sslContext()
Returns the ssl context
-
sslContext
public ClientBuilder sslContext(io.netty.handler.ssl.SslContext sslContext)
SSL/TLS context to use instead of the system default. It must have been configured withGrpcSslContexts, but options could have been overridden.- Parameters:
sslContext- the ssl context- Returns:
- this builder
-
sslContext
public ClientBuilder sslContext(java.util.function.Consumer<io.netty.handler.ssl.SslContextBuilder> consumer) throws javax.net.ssl.SSLException
Configure SSL/TLS context create throughGrpcSslContexts.forClient()to use.- Parameters:
consumer- the SslContextBuilder consumer- Returns:
- this builder
- Throws:
javax.net.ssl.SSLException- if the SslContextBuilder fails
-
authority
public java.lang.String authority()
Returns The authority used to authenticate connections to servers.
-
authority
public ClientBuilder authority(java.lang.String authority)
Sets the authority used to authenticate connections to servers.- Parameters:
authority- the authority used to authenticate connections to servers.- Returns:
- this builder
-
maxInboundMessageSize
public java.lang.Integer maxInboundMessageSize()
Returns the maximum message size allowed for a single gRPC frame.
-
maxInboundMessageSize
public ClientBuilder maxInboundMessageSize(java.lang.Integer maxInboundMessageSize)
Sets the maximum message size allowed for a single gRPC frame.- Parameters:
maxInboundMessageSize- the maximum message size allowed for a single gRPC frame.- Returns:
- this builder
-
headers
public java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object> headers()
Returns the headers to be added to http request headers
-
headers
public ClientBuilder headers(java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object> headers)
Sets headers to be added to http request headers.- Parameters:
headers- headers to be added to http request headers.- Returns:
- this builder
-
header
public ClientBuilder header(java.lang.String key, java.lang.String value)
Set headers.- Parameters:
key- Sets an header key to be added to http request headers.value- Sets an header value to be added to http request headers.- Returns:
- this builder
-
authHeaders
public java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object> authHeaders()
Returns the headers to be added to auth request headers
-
authHeaders
public ClientBuilder authHeaders(java.util.Map<io.grpc.Metadata.Key<?>,java.lang.Object> authHeaders)
Set the auth headers.- Parameters:
authHeaders- Sets headers to be added to auth request headers.- Returns:
- this builder
-
authHeader
public ClientBuilder authHeader(java.lang.String key, java.lang.String value)
Add an auth header.- Parameters:
key- Sets an header key to be added to auth request headers.value- Sets an header value to be added to auth request headers.- Returns:
- this builder
-
interceptors
public java.util.List<io.grpc.ClientInterceptor> interceptors()
Returns the interceptors
-
interceptors
public ClientBuilder interceptors(java.util.List<io.grpc.ClientInterceptor> interceptors)
Set the interceptors.- Parameters:
interceptors- the interceptors.- Returns:
- this builder
-
interceptor
public ClientBuilder interceptor(io.grpc.ClientInterceptor interceptor, io.grpc.ClientInterceptor... interceptors)
Add an interceptor.- Parameters:
interceptor- an interceptors to addinterceptors- additional interceptors- Returns:
- this builder
-
authInterceptors
public java.util.List<io.grpc.ClientInterceptor> authInterceptors()
Returns the auth interceptors
-
authInterceptors
public ClientBuilder authInterceptors(java.util.List<io.grpc.ClientInterceptor> interceptors)
Set the auth interceptors.- Parameters:
interceptors- Set the interceptors to add to the auth chain- Returns:
- this builder
-
authInterceptors
public ClientBuilder authInterceptors(io.grpc.ClientInterceptor interceptor, io.grpc.ClientInterceptor... interceptors)
Add an auth interceptor.- Parameters:
interceptor- an interceptors to add to the auth chaininterceptors- additional interceptors to add to the auth chain- Returns:
- this builder
-
retryDelay
public long retryDelay()
Returns The delay between retries.
-
retryDelay
public ClientBuilder retryDelay(long retryDelay)
The delay between retries.- Parameters:
retryDelay- The delay between retries.- Returns:
- this builder
-
retryMaxDelay
public long retryMaxDelay()
Returns the max backing off delay between retries
-
retryMaxDelay
public ClientBuilder retryMaxDelay(long retryMaxDelay)
Set the max backing off delay between retries.- Parameters:
retryMaxDelay- The max backing off delay between retries.- Returns:
- this builder
-
keepaliveTime
public java.time.Duration keepaliveTime()
-
keepaliveTime
public ClientBuilder keepaliveTime(java.time.Duration keepaliveTime)
The interval for gRPC keepalives. The current minimum allowed by gRPC is 10s- Parameters:
keepaliveTime- time between keepalives- Returns:
- this builder
-
keepaliveTimeout
public java.time.Duration keepaliveTimeout()
-
keepaliveTimeout
public ClientBuilder keepaliveTimeout(java.time.Duration keepaliveTimeout)
The timeout for gRPC keepalives- Parameters:
keepaliveTimeout- the gRPC keep alive timeout.- Returns:
- this builder
-
keepaliveWithoutCalls
public java.lang.Boolean keepaliveWithoutCalls()
-
keepaliveWithoutCalls
public ClientBuilder keepaliveWithoutCalls(java.lang.Boolean keepaliveWithoutCalls)
Keepalive option for gRPC- Parameters:
keepaliveWithoutCalls- the gRPC keep alive without calls.- Returns:
- this builder
-
retryChronoUnit
public java.time.temporal.ChronoUnit retryChronoUnit()
Returns he retries period unit.
-
retryChronoUnit
public ClientBuilder retryChronoUnit(java.time.temporal.ChronoUnit retryChronoUnit)
Sets the retries period unit.- Parameters:
retryChronoUnit- the retries period unit.- Returns:
- this builder
-
retryMaxDuration
public java.time.Duration retryMaxDuration()
Returns the retries max duration.
-
connectTimeout
public java.time.Duration connectTimeout()
Returns the connect timeout.
-
retryMaxDuration
public ClientBuilder retryMaxDuration(java.time.Duration retryMaxDuration)
Set the retries max duration.- Parameters:
retryMaxDuration- the retries max duration.- Returns:
- this builder
-
connectTimeout
public ClientBuilder connectTimeout(java.time.Duration connectTimeout)
Set the connection timeout.- Parameters:
connectTimeout- Sets the connection timeout. Clients connecting to fault tolerant etcd clusters (eg, clusters with more than 2 etcd server peers/endpoints) should consider a value that will allow switching timely from a crashed/partitioned peer to a consensus peer.- Returns:
- this builder
-
waitForReady
public boolean waitForReady()
Enable gRPC's wait for ready semantics.- Returns:
- if this client uses gRPC's wait for ready semantics.
- See Also:
- gRPC Wait for Ready Semantics
-
waitForReady
public ClientBuilder waitForReady(boolean waitForReady)
Configure the gRPC's wait for ready semantics.- Parameters:
waitForReady- if this client should use gRPC's wait for ready semantics. Enabled by default.- Returns:
- this builder.
- See Also:
- gRPC Wait for Ready Semantics
-
build
public Client build()
build a new Client.- Returns:
- Client instance.
- Throws:
io.etcd.jetcd.common.exception.EtcdException- if client experiences build error.
-
copy
public ClientBuilder copy()
Returns a copy of this builder
-
-