This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d0a04fca [#4228] support configuration sorted by updateTime (#4229)
3d0a04fca is described below

commit 3d0a04fca08f152ce4250e2f1af0b3f469780597
Author: Cheng YouLing <[email protected]>
AuthorDate: Mon Feb 5 17:34:32 2024 +0800

    [#4228] support configuration sorted by updateTime (#4229)
---
 .../org/apache/servicecomb/config/kie/client/KieClient.java   |  2 ++
 .../org/apache/servicecomb/config/kie/client/model/KVDoc.java | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git 
a/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/KieClient.java
 
b/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/KieClient.java
index ec567f90c..d28185fb7 100644
--- 
a/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/KieClient.java
+++ 
b/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/KieClient.java
@@ -20,6 +20,7 @@ package org.apache.servicecomb.config.kie.client;
 import java.io.StringReader;
 import java.nio.charset.StandardCharsets;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -125,6 +126,7 @@ public class KieClient implements KieConfigOperation {
   private Map<String, Object> getConfigByLabel(KVResponse resp) {
     Map<String, Object> resultMap = new HashMap<>();
     resp.getData().stream()
+        .sorted(Comparator.comparing(KVDoc::getUpdateTime, 
Comparator.nullsFirst(Comparator.naturalOrder())))
         .filter(doc -> doc.getStatus() == null || 
ConfigConstants.STATUS_ENABLED.equalsIgnoreCase(doc.getStatus()))
         .map(this::processValueType)
         .collect(Collectors.toList())
diff --git 
a/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/model/KVDoc.java
 
b/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/model/KVDoc.java
index 4078557d3..3059a581c 100644
--- 
a/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/model/KVDoc.java
+++ 
b/clients/config-kie-client/src/main/java/org/apache/servicecomb/config/kie/client/model/KVDoc.java
@@ -44,6 +44,9 @@ public class KVDoc {
 
   private String status;
 
+  @JsonAlias("update_time")
+  private long updateTime;
+
   public String getStatus() {
     return status;
   }
@@ -115,4 +118,12 @@ public class KVDoc {
   public String getValueType() {
     return valueType;
   }
+
+  public long getUpdateTime() {
+    return updateTime;
+  }
+
+  public void setUpdateTime(long updateTime) {
+    this.updateTime = updateTime;
+  }
 }

Reply via email to