Skip to content

Commit 57710eb

Browse files
committed
Fix incorrectly creation of Service reference
1 parent dd036dd commit 57710eb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/core-service-discovery/src/main/java/ai/wanaku/core/service/discovery/ValkeyRegistry.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public void deregister(String service) {
6767
@Override
6868
public Service getService(String service) {
6969
try (io.valkey.Jedis jedis = jedisPool.getResource()) {
70-
Set<String> configs = jedis.hkeys(service);
71-
return toService(jedis, configs);
70+
return newService(jedis, service);
7271
}
7372
}
7473

@@ -80,11 +79,7 @@ public Map<String, Service> getEntries(ServiceType serviceType) {
8079
for (String key : keys) {
8180
String sType = jedis.hget(key, ReservedKeys.WANAKU_TARGET_TYPE);
8281
if (serviceType.asValue().equals(sType)) {
83-
Set<String> configs = jedis.hkeys(key);
84-
85-
Service service = toService(jedis, configs);
86-
String address = jedis.hget(key, ReservedKeys.WANAKU_TARGET_ADDRESS);
87-
service.setTarget(address);
82+
Service service = newService(jedis, key);
8883

8984
entries.put(key, service);
9085
}
@@ -96,7 +91,12 @@ public Map<String, Service> getEntries(ServiceType serviceType) {
9691
return entries;
9792
}
9893

99-
private static Service toService(Jedis jedis, Set<String> configs) {
94+
private static Service newService(Jedis jedis, String key) {
95+
Set<String> configs = jedis.hkeys(key);
96+
return toService(jedis, key, configs);
97+
}
98+
99+
private static Service toService(Jedis jedis, String key, Set<String> configs) {
100100
Service service = new Service();
101101

102102
Map<String, Configuration> configurationMap = new HashMap<>();
@@ -112,6 +112,9 @@ private static Service toService(Jedis jedis, Set<String> configs) {
112112
configurations.setConfigurations(configurationMap);
113113
service.setConfigurations(configurations);
114114

115+
String address = jedis.hget(key, ReservedKeys.WANAKU_TARGET_ADDRESS);
116+
service.setTarget(address);
117+
115118
return service;
116119
}
117120

0 commit comments

Comments
 (0)