Package io.etcd.jetcd

Class ClientBuilder

java.lang.Object
io.etcd.jetcd.ClientBuilder
All Implemented Interfaces:
Cloneable

public final class ClientBuilder extends Object implements Cloneable
ClientBuilder knows how to create a Client instance.
  • Method Details

    • target

      public String target()
      Gets the etcd target.
      Returns:
      the etcd target.
    • target

      public ClientBuilder target(String target)
      configure etcd server endpoints.
      Parameters:
      target - etcd server target
      Returns:
      this builder to train
      Throws:
      NullPointerException - if target is null or one of endpoint is null
    • endpoints

      public ClientBuilder endpoints(String... endpoints)
      configure etcd server endpoints using the IPNameResolver.
      Parameters:
      endpoints - etcd server endpoints, at least one
      Returns:
      this builder to train
      Throws:
      NullPointerException - if endpoints is null or one of endpoint is null
      IllegalArgumentException - if some endpoint is invalid
    • endpoints

      public ClientBuilder endpoints(URI... endpoints)
      configure etcd server endpoints using the IPNameResolver.
      Parameters:
      endpoints - etcd server endpoints, at least one
      Returns:
      this builder to train
      Throws:
      NullPointerException - if endpoints is null or one of endpoint is null
      IllegalArgumentException - if some endpoint is invalid
    • endpoints

      public ClientBuilder endpoints(Iterable<URI> endpoints)
      configure etcd server endpoints using the IPNameResolver.
      Parameters:
      endpoints - etcd server endpoints, at least one
      Returns:
      this builder to train
      Throws:
      NullPointerException - if endpoints is null or one of endpoint is null
      IllegalArgumentException - if some endpoint is invalid
    • user

      public ByteSequence user()
      Returns the auth user
      Returns:
      the user.
    • user

      public ClientBuilder user(ByteSequence user)
      config etcd auth user.
      Parameters:
      user - etcd auth user
      Returns:
      this builder
      Throws:
      NullPointerException - if user is null
    • password

      public ByteSequence password()
      Returns the auth password
      Returns:
      the password.
    • password

      public ClientBuilder password(ByteSequence password)
      config etcd auth password.
      Parameters:
      password - etcd auth password
      Returns:
      this builder
      Throws:
      NullPointerException - if password is null
    • namespace

      public ByteSequence namespace()
      Returns the namespace of each key used
      Returns:
      the namespace.
    • namespace

      public ClientBuilder namespace(ByteSequence namespace)
      config the namespace of keys used in KV, Txn, Lock and Watch. "/" will be treated as no namespace.
      Parameters:
      namespace - the namespace of each key used
      Returns:
      this builder
      Throws:
      NullPointerException - if namespace is null
    • executorService

      public ExecutorService executorService()
      Returns the executor service
      Returns:
      the executor service.
    • executorService

      public ClientBuilder executorService(ExecutorService executorService)
      config executor service.
      Parameters:
      executorService - executor service
      Returns:
      this builder
      Throws:
      NullPointerException - if executorService is null
    • loadBalancerPolicy

      public ClientBuilder loadBalancerPolicy(String loadBalancerPolicy)
      config load balancer policy.
      Parameters:
      loadBalancerPolicy - etcd load balancer policy
      Returns:
      this builder
      Throws:
      NullPointerException - if loadBalancerPolicy is null
    • loadBalancerPolicy

      public String loadBalancerPolicy()
      get the load balancer policy for etcd client.
      Returns:
      loadBalancerFactory
    • sslContext

      public io.netty.handler.ssl.SslContext sslContext()
      Returns the ssl context
      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 with GrpcSslContexts, but options could have been overridden.
      Parameters:
      sslContext - the ssl context
      Returns:
      this builder
    • sslContext

      public ClientBuilder sslContext(Consumer<io.netty.handler.ssl.SslContextBuilder> consumer) throws SSLException
      Configure SSL/TLS context create through GrpcSslContexts.forClient() to use.
      Parameters:
      consumer - the SslContextBuilder consumer
      Returns:
      this builder
      Throws:
      SSLException - if the SslContextBuilder fails
    • authority

      public String authority()
      Returns The authority used to authenticate connections to servers.
      Returns:
      the authority.
    • authority

      public ClientBuilder authority(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 Integer maxInboundMessageSize()
      Returns the maximum message size allowed for a single gRPC frame.
      Returns:
      max inbound message size.
    • maxInboundMessageSize

      public ClientBuilder maxInboundMessageSize(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 Map<io.grpc.Metadata.Key<?>,Object> headers()
      Returns the headers to be added to http request headers
      Returns:
      headers.
    • headers

      public ClientBuilder headers(Map<io.grpc.Metadata.Key<?>,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(String key, 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 Map<io.grpc.Metadata.Key<?>,Object> authHeaders()
      Returns the headers to be added to auth request headers
      Returns:
      auth headers.
    • authHeaders

      public ClientBuilder authHeaders(Map<io.grpc.Metadata.Key<?>,Object> authHeaders)
      Set the auth headers.
      Parameters:
      authHeaders - Sets headers to be added to auth request headers.
      Returns:
      this builder
    • authHeader

      public ClientBuilder authHeader(String key, 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 List<io.grpc.ClientInterceptor> interceptors()
      Returns the interceptors
      Returns:
      the interceptors.
    • interceptors

      public ClientBuilder interceptors(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 add
      interceptors - additional interceptors
      Returns:
      this builder
    • authInterceptors

      public List<io.grpc.ClientInterceptor> authInterceptors()
      Returns the auth interceptors
      Returns:
      the interceptors.
    • authInterceptors

      public ClientBuilder authInterceptors(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 chain
      interceptors - additional interceptors to add to the auth chain
      Returns:
      this builder
    • retryDelay

      public long retryDelay()
      Returns The delay between retries.
      Returns:
      the retry delay.
    • 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
      Returns:
      max retry delay.
    • 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
    • retryMaxAttempts

      public int retryMaxAttempts()
      Returns the max number of retry attempts
      Returns:
      max retry attempts.
    • retryMaxAttempts

      public ClientBuilder retryMaxAttempts(int retryMaxAttempts)
      Set the max number of retry attempts
      Parameters:
      retryMaxAttempts - The max retry attempts.
      Returns:
      this builder
    • keepaliveTime

      public Duration keepaliveTime()
      Returns the keep alive time.
      Returns:
      keep alive time.
    • keepaliveTime

      public ClientBuilder keepaliveTime(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 Duration keepaliveTimeout()
      Returns the keep alive time out.
      Returns:
      keep alive time out.
    • keepaliveTimeout

      public ClientBuilder keepaliveTimeout(Duration keepaliveTimeout)
      The timeout for gRPC keepalives
      Parameters:
      keepaliveTimeout - the gRPC keep alive timeout.
      Returns:
      this builder
    • keepaliveWithoutCalls

      public Boolean keepaliveWithoutCalls()
    • keepaliveWithoutCalls

      public ClientBuilder keepaliveWithoutCalls(Boolean keepaliveWithoutCalls)
      Keepalive option for gRPC
      Parameters:
      keepaliveWithoutCalls - the gRPC keep alive without calls.
      Returns:
      this builder
    • retryChronoUnit

      public ChronoUnit retryChronoUnit()
      Returns he retries period unit.
      Returns:
      the chrono unit.
    • retryChronoUnit

      public ClientBuilder retryChronoUnit(ChronoUnit retryChronoUnit)
      Sets the retries period unit.
      Parameters:
      retryChronoUnit - the retries period unit.
      Returns:
      this builder
    • retryMaxDuration

      public Duration retryMaxDuration()
      Returns the retries max duration.
      Returns:
      retry max duration.
    • connectTimeout

      public Duration connectTimeout()
      Returns the connect timeout.
      Returns:
      connect timeout.
    • retryMaxDuration

      public ClientBuilder retryMaxDuration(Duration retryMaxDuration)
      Set the retries max duration.
      Parameters:
      retryMaxDuration - the retries max duration.
      Returns:
      this builder
    • connectTimeout

      public ClientBuilder connectTimeout(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:
    • 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:
    • 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
      Returns:
      a copy of the builder.