1+ /*
2+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
3+ * All rights reserved. This program and the accompanying materials
4+ * are made available under the terms of the Eclipse Public License v1.0
5+ * and Apache License v2.0 which accompanies this distribution.
6+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+ * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+ *
9+ * You may elect to redistribute this code under either of these licenses.
10+ *
11+ * Contributors:
12+ *
13+ * Maximillian Arruda
14+ */
15+
16+ package org .eclipse .jnosql .databases .redis .communication ;
17+
18+ import redis .clients .jedis .Protocol ;
19+
20+ import java .util .function .Supplier ;
21+
22+ /**
23+ * An enumeration to show the available options to connect to the Redis database by cluster configuration.
24+ * It implements {@link Supplier}, where its it returns the property name that might be
25+ * overwritten by the system environment using Eclipse Microprofile or Jakarta Config API.
26+ *
27+ * @see org.eclipse.jnosql.communication.Settings
28+ */
29+ public enum RedisClusterConfigurations implements Supplier <String > {
30+ /**
31+ * The value for the sentinel basic configuration attribute for the jedis client configuration with this configuration instance.
32+ */
33+ CLUSTER ("jnosql.redis.cluster" ),
34+ /**
35+ * The value for the sentinel HOST:PORT (separated by comma) configuration attribute for the jedis client configuration with this configuration instance.
36+ */
37+ CLUSTER_HOSTS ("jnosql.redis.cluster.hosts" ),
38+ /**
39+ * The cluster client's name. The default value is 0.
40+ */
41+ CLIENT_NAME ("jnosql.redis.cluster.client.name" ),
42+ /**
43+ * The cluster redis timeout. The default value is {@link Protocol#DEFAULT_TIMEOUT}
44+ */
45+ TIMEOUT ("jnosql.redis.cluster.timeout" ),
46+ /**
47+ * The value for the connection timeout in milliseconds configuration attribute for the cluster jedis client configuration
48+ * created with this configuration instance.
49+ * The connection timeout on millis on {@link redis.clients.jedis.JedisClientConfig}, the default value is {@link Protocol#DEFAULT_TIMEOUT}
50+ */
51+ CONNECTION_TIMEOUT ("jnosql.redis.cluster.connection.timeout" ),
52+ /**
53+ * The value for the socket timeout in milliseconds configuration attribute for the cluster jedis client configuration with
54+ * this configuration instance.
55+ * The socket timeout on millis on {@link redis.clients.jedis.JedisClientConfig}, the default is {@link Protocol#DEFAULT_TIMEOUT}
56+ */
57+ SOCKET_TIMEOUT ("jnosql.redis.cluster.socket.timeout" ),
58+ /**
59+ * The value for the user configuration attribute for the cluster jedis client configuration with this configuration instance.
60+ * The user on {@link redis.clients.jedis.JedisClientConfig}
61+ */
62+ USER ("jnosql.redis.cluster.user" ),
63+ /**
64+ * The value for the password configuration attribute for the cluster jedis client configuration with this configuration instance.
65+ * The user on {@link redis.clients.jedis.JedisClientConfig}
66+ */
67+ PASSWORD ("jnosql.redis.cluster.password" ),
68+ /**
69+ * The value for the ssl configuration attribute for the cluster jedis client configuration with this configuration instance.
70+ * The ssl on {@link redis.clients.jedis.JedisClientConfig}, the default value is false.
71+ */
72+ SSL ("jnosql.redis.cluster.ssl" ),
73+ /**
74+ * The value for the protocol configuration attribute for the cluster jedis client configuration with this configuration instance.
75+ * The protocol on {@link redis.clients.jedis.JedisClientConfig}
76+ */
77+ REDIS_PROTOCOL ("jnosql.redis.cluster.protocol" ),
78+ /**
79+ * The value for the clientset info disabled configuration attribute for the cluster jedis client configuration with this configuration instance.
80+ * The clientset info disabled on {@link redis.clients.jedis.JedisClientConfig}
81+ */
82+ CLIENTSET_INFO_CONFIG_DISABLED ("jnosql.redis.cluster.clientset.info.config.disabled" ),
83+ /**
84+ * The value for the clientset info configuration libname suffix attribute for the cluster jedis client configuration with this configuration instance.
85+ * The clientset info libname suffix on {@link redis.clients.jedis.JedisClientConfig}
86+ */
87+ CLIENTSET_INFO_CONFIG_LIBNAME_SUFFIX ("jnosql.redis.cluster.clientset.info.config.libname.suffix" ),
88+
89+ /**
90+ * The value for the max attempts configuration attribute for the cluster jedis client configuration with this configuration instance.
91+ * Default is {@link redis.clients.jedis.JedisCluster#DEFAULT_MAX_ATTEMPTS}
92+ */
93+ CLUSTER_MAX_ATTEMPTS ("jnosql.redis.cluster.max.attempts" ),
94+ /**
95+ * The value for the max total retries configuration attribute for the cluster jedis client configuration with this configuration instance.
96+ * Default is {@link RedisClusterConfigurations#SOCKET_TIMEOUT} * {@link RedisClusterConfigurations#CLUSTER_MAX_ATTEMPTS}
97+ */
98+ CLUSTER_MAX_TOTAL_RETRIES_DURATION ("jnosql.redis.cluster.max.total.retries.duration" );
99+
100+ private final String configuration ;
101+
102+ RedisClusterConfigurations (String configuration ) {
103+ this .configuration = configuration ;
104+ }
105+
106+ @ Override
107+ public String get () {
108+ return configuration ;
109+ }
110+
111+ public static enum ClusterConfigurationsResolver implements
112+ RedisConfigurationsResolver {
113+
114+ INSTANCE ;
115+
116+ @ Override
117+ public Supplier <String > connectionTimeoutSupplier () {
118+ return RedisClusterConfigurations .CONNECTION_TIMEOUT ;
119+ }
120+
121+ @ Override
122+ public Supplier <String > socketTimeoutSupplier () {
123+ return RedisClusterConfigurations .SOCKET_TIMEOUT ;
124+ }
125+
126+ @ Override
127+ public Supplier <String > clientNameSupplier () {
128+ return RedisClusterConfigurations .CLIENT_NAME ;
129+ }
130+
131+ @ Override
132+ public Supplier <String > userSupplier () {
133+ return RedisClusterConfigurations .USER ;
134+ }
135+
136+ @ Override
137+ public Supplier <String > passwordSupplier () {
138+ return RedisClusterConfigurations .PASSWORD ;
139+ }
140+
141+ @ Override
142+ public Supplier <String > timeoutSupplier () {
143+ return RedisClusterConfigurations .TIMEOUT ;
144+ }
145+
146+ @ Override
147+ public Supplier <String > sslSupplier () {
148+ return RedisClusterConfigurations .SSL ;
149+ }
150+
151+ @ Override
152+ public Supplier <String > redisProtocolSupplier () {
153+ return RedisClusterConfigurations .REDIS_PROTOCOL ;
154+ }
155+
156+ @ Override
157+ public Supplier <String > clientsetInfoConfigLibNameSuffixSupplier () {
158+ return RedisClusterConfigurations .CLIENTSET_INFO_CONFIG_LIBNAME_SUFFIX ;
159+ }
160+
161+ @ Override
162+ public Supplier <String > clientsetInfoConfigDisabled () {
163+ return RedisClusterConfigurations .CLIENTSET_INFO_CONFIG_DISABLED ;
164+ }
165+ }
166+
167+ }
0 commit comments