Skip to content

Commit

Permalink
fix(service-registry): Fix etcd service version acquisition problem
Browse files Browse the repository at this point in the history
- Update the EtcdConfigIT test case to use specific version numbers instead of general configurations
- Modify the EtcdDiscovery class to improve version information extraction logic
- Optimize code structure to improve readability and performance
  • Loading branch information
SweetWuXiaoMei committed Nov 14, 2024
1 parent 9ab3442 commit 13c8de0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void testService() {

private void testVersion() {

putValue("/servicecomb/config/version/production/demo-etcd/provider/application.properties",
putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application.properties",
"test3=version");
putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application.properties",
"test4=version4");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -164,7 +165,15 @@ public List<String> findServices(String application) {
waiter.executeTaskAsync(() -> {
String prefixPath = basePath + "/" + application;
List<KeyValue> endpointKv = getValuesByPrefix(prefixPath);
return endpointKv.stream().map(kv -> kv.getKey().toString(StandardCharsets.UTF_8)).collect(Collectors.toList());
return endpointKv.stream()
.map(kv -> kv.getKey().toString(StandardCharsets.UTF_8))
.map(key -> {
String[] parts = StringUtils.split(key, "/");
return parts.length > 5 ? parts[4] : null;
})
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
});
return waiter.waitForCompletion();
}
Expand Down

0 comments on commit 13c8de0

Please sign in to comment.