|
1 | 1 | package com.redis.vl.redis; |
2 | 2 |
|
3 | 3 | import java.util.ArrayList; |
| 4 | +import java.util.Collections; |
4 | 5 | import java.util.List; |
5 | 6 | import lombok.Builder; |
6 | 7 | import lombok.Getter; |
| 8 | +import lombok.Singular; |
7 | 9 |
|
8 | 10 | /** |
9 | 11 | * Configuration for Redis Sentinel connections. |
|
13 | 15 | * |
14 | 16 | * <p>Python reference: redisvl/redis/connection.py - _parse_sentinel_url |
15 | 17 | */ |
16 | | -@Getter |
17 | 18 | @Builder |
18 | 19 | public class SentinelConfig { |
19 | 20 |
|
20 | 21 | /** List of Sentinel host:port pairs */ |
21 | | - private final List<HostPort> sentinelHosts; |
| 22 | + @Singular private final List<HostPort> sentinelHosts; |
22 | 23 |
|
23 | 24 | /** Sentinel service/master name (default: "mymaster") */ |
24 | | - @Builder.Default private final String serviceName = "mymaster"; |
| 25 | + @Getter @Builder.Default private final String serviceName = "mymaster"; |
25 | 26 |
|
26 | 27 | /** Redis database number (optional) */ |
27 | | - private final Integer database; |
| 28 | + @Getter private final Integer database; |
28 | 29 |
|
29 | 30 | /** Username for authentication (optional) */ |
30 | | - private final String username; |
| 31 | + @Getter private final String username; |
31 | 32 |
|
32 | 33 | /** Password for authentication (optional) */ |
33 | | - private final String password; |
| 34 | + @Getter private final String password; |
34 | 35 |
|
35 | 36 | /** Connection timeout in milliseconds */ |
36 | | - @Builder.Default private final int connectionTimeout = 2000; |
| 37 | + @Getter @Builder.Default private final int connectionTimeout = 2000; |
37 | 38 |
|
38 | 39 | /** Socket timeout in milliseconds */ |
39 | | - @Builder.Default private final int socketTimeout = 2000; |
| 40 | + @Getter @Builder.Default private final int socketTimeout = 2000; |
| 41 | + |
| 42 | + /** |
| 43 | + * Get an unmodifiable view of the Sentinel hosts list. |
| 44 | + * |
| 45 | + * @return Unmodifiable list of Sentinel host:port pairs |
| 46 | + */ |
| 47 | + public List<HostPort> getSentinelHosts() { |
| 48 | + return Collections.unmodifiableList(sentinelHosts); |
| 49 | + } |
40 | 50 |
|
41 | 51 | /** |
42 | 52 | * Parse a Sentinel URL into a SentinelConfig. |
@@ -216,7 +226,7 @@ private static HostPort parseHostPort(String hostPort) { |
216 | 226 |
|
217 | 227 | /** Represents a host:port pair for Sentinel nodes */ |
218 | 228 | @Getter |
219 | | - public static class HostPort { |
| 229 | + public static final class HostPort { |
220 | 230 | private final String host; |
221 | 231 | private final int port; |
222 | 232 |
|
|
0 commit comments