Class BaseClientConfiguration.BaseClientConfigurationBuilder<C extends BaseClientConfiguration,​B extends BaseClientConfiguration.BaseClientConfigurationBuilder<C,​B>>

    • Constructor Detail

      • BaseClientConfigurationBuilder

        public BaseClientConfigurationBuilder()
    • Method Detail

      • addresses

        public B addresses​(java.util.Collection<? extends NodeAddress> addresses)
      • clearAddresses

        public B clearAddresses()
      • useTLS

        public B useTLS​(boolean useTLS)
        True if communication with the cluster should use Transport Level Security.

        If the server/cluster requires TLS, not setting this will cause the connection attempt to fail.

        If the server/cluster doesn't require TLS, setting this will also cause the connection attempt to fail.

        Returns:
        this.
      • readFrom

        public B readFrom​(@NonNull
                          @NonNull ReadFrom readFrom)
        Represents the client's read from strategy.
        Returns:
        this.
      • credentials

        public B credentials​(ServerCredentials credentials)
        Credentials for authentication process. If none are set, the client will not authenticate itself with the server.
        Returns:
        this.
      • requestTimeout

        public B requestTimeout​(java.lang.Integer requestTimeout)
        The duration in milliseconds that the client should wait for a request to complete. This duration encompasses sending the request, awaiting for a response from the server, and any required reconnection or retries. If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not explicitly set, a default value of 250 milliseconds will be used.
        Returns:
        this.
      • clientName

        public B clientName​(java.lang.String clientName)
        Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment.
        Returns:
        this.
      • libName

        public B libName​(java.lang.String libName)
        Library name to be used for the client. Will be used with CLIENT SETINFO LIB-NAME command during connection establishment.
        Returns:
        this.
      • inflightRequestsLimit

        public B inflightRequestsLimit​(java.lang.Integer inflightRequestsLimit)
        The maximum number of concurrent requests allowed to be in-flight (sent but not yet completed). This limit is used to control the memory usage and prevent the client from overwhelming the server or getting stuck in case of a queue backlog. If not set, a default value of 1000 will be used.
        Returns:
        this.
      • clientAZ

        public B clientAZ​(java.lang.String clientAZ)
        Availability Zone of the client. If ReadFrom strategy is AZAffinity or AZAffinityReplicasAndPrimary, this setting ensures that readonly commands are directed to nodes within the specified AZ if exits.
        Returns:
        this.
      • reconnectStrategy

        public B reconnectStrategy​(BackoffStrategy reconnectStrategy)
        Strategy used to determine how and when to reconnect, in case of connection failures.
        Returns:
        this.
      • databaseId

        public B databaseId​(java.lang.Integer databaseId)
        Index of the logical database to connect to. Must be non-negative and within the range supported by the server configuration. If not specified, defaults to database 0.
        Returns:
        this.
      • lazyConnect

        public B lazyConnect​(boolean lazyConnect)
        Enables lazy connection mode, where physical connections to the server(s) are deferred until the first command is sent. This can reduce startup latency and allow for client creation in disconnected environments.

        When set to true, the client will not attempt to connect to the specified nodes during initialization. Instead, connections will be established only when a command is actually executed.

        Note that the first command executed with lazy connections may experience additional latency as it needs to establish the connection first. During this initial connection, the standard request timeout does not apply yet - instead, the connection establishment is governed by connectionTimeout. The request timeout (requestTimeout) only begins counting after the connection has been successfully established. This behavior can effectively increase the total time needed for the first command to complete.

        This setting applies to both standalone and cluster modes. Note that if an operation is attempted and connection fails (e.g., unreachable nodes), errors will surface at that point.

        If not set, connections are established immediately during client creation (equivalent to false).

        Returns:
        this.
      • addressResolver

        public B addressResolver​(AddressResolver addressResolver)
        Optional callback for resolving server addresses before connection.

        If provided, this callback will be invoked for each configured address during connection establishment. The callback receives the configured host and port, and should return the actual host and port to use for the connection.

        This is useful for:

        • Custom DNS resolution for service discovery
        • Address translation for proxy setups
        • Dynamic endpoint resolution for cloud environments

        If not set, addresses are used as configured without modification.

        Returns:
        this.
        Example:
        
         AddressResolver resolver = (host, port) -> {
             String resolvedHost = myDnsResolver.resolve(host);
             return new ResolvedAddress(resolvedHost, port);
         };
        
         GlideClientConfiguration config = GlideClientConfiguration.builder()
             .address(NodeAddress.builder().host("my-service").port(6379).build())
             .addressResolver(resolver)
             .build();
         
      • compressionConfiguration

        public B compressionConfiguration​(CompressionConfiguration compressionConfiguration)
        Returns:
        this.
      • self

        protected abstract B self()
      • build

        public abstract C build()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object