@Override
    public List<InstanceEntity> selectInstances(final String selectKey) {
        final String watchKey = InstancePathConstants.buildInstanceParentPath(selectKey);
        final Function<Map<String, String>, List<InstanceEntity>> getInstanceRegisterFun = childrenList ->
                childrenList.values().stream().map(x -> {
                    InstanceEntity instanceEntity = GsonUtils.getInstance().fromJson(x, InstanceEntity.class);
                    instanceEntity.setUri(getURI(x, instanceEntity.getPort(), instanceEntity.getHost()));
                    return instanceEntity;
                }).collect(Collectors.toList());
        if (watcherInstanceRegisterMap.containsKey(selectKey)) {
            return getInstanceRegisterFun.apply(client.getKeysMapByPrefix(watchKey));
        }
        Map<String, String> serverNodes = client.getKeysMapByPrefix(watchKey);
        this.client.watchKeyChanges(watchKey, Watch.listener(response -> {
            for (WatchEvent event : response.getEvents()) {
                String value = event.getKeyValue().getValue().toString(StandardCharsets.UTF_8);
                String path = event.getKeyValue().getKey().toString(StandardCharsets.UTF_8);
                switch (event.getEventType()) {
                    case PUT:
                        serverNodes.put(path, value);
                        LOGGER.info("watch key {} updated, value is {}", watchKey, value);
                        continue;
                    case DELETE:
                        serverNodes.remove(path);
                        LOGGER.info("watch key {} deleted, key is {}", watchKey, path);
                        continue;
                    default:
                }
            }
            watcherInstanceRegisterMap.put(selectKey, getInstanceRegisterFun.apply(serverNodes));
        }));
        final List<InstanceEntity> instanceEntities = getInstanceRegisterFun.apply(serverNodes);
        watcherInstanceRegisterMap.put(selectKey, instanceEntities);
        return instanceEntities;
    }
The type Etcd instance register repository.
shenyu-registry/shenyu-registry-etcd/src/main/java/org/apache/shenyu/registry/etcd/EtcdInstanceRegisterRepository.java