@@ -67,8 +67,7 @@ public void deregister(String service) {
67
67
@ Override
68
68
public Service getService (String service ) {
69
69
try (io .valkey .Jedis jedis = jedisPool .getResource ()) {
70
- Set <String > configs = jedis .hkeys (service );
71
- return toService (jedis , configs );
70
+ return newService (jedis , service );
72
71
}
73
72
}
74
73
@@ -80,11 +79,7 @@ public Map<String, Service> getEntries(ServiceType serviceType) {
80
79
for (String key : keys ) {
81
80
String sType = jedis .hget (key , ReservedKeys .WANAKU_TARGET_TYPE );
82
81
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 );
88
83
89
84
entries .put (key , service );
90
85
}
@@ -96,7 +91,12 @@ public Map<String, Service> getEntries(ServiceType serviceType) {
96
91
return entries ;
97
92
}
98
93
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 ) {
100
100
Service service = new Service ();
101
101
102
102
Map <String , Configuration > configurationMap = new HashMap <>();
@@ -112,6 +112,9 @@ private static Service toService(Jedis jedis, Set<String> configs) {
112
112
configurations .setConfigurations (configurationMap );
113
113
service .setConfigurations (configurations );
114
114
115
+ String address = jedis .hget (key , ReservedKeys .WANAKU_TARGET_ADDRESS );
116
+ service .setTarget (address );
117
+
115
118
return service ;
116
119
}
117
120
0 commit comments