wu-sheng commented on code in PR #11099:
URL: https://github.com/apache/skywalking/pull/11099#discussion_r1264686727


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/management/ui/menu/UIMenuManagementService.java:
##########
@@ -35,25 +40,29 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
 @Slf4j
-public class UIMenuManagementService implements Service, Runnable {
+public class UIMenuManagementService implements Service {
     private static final String MENU_ID = "1";
     private static final Gson GSON = new Gson();
-    private static final int MENU_GET_MAX_SECOND = 3;
 
+    private final LoadingCache<Boolean, List<MenuItem>> menuItemCache;
     private UIMenuManagementDAO menuDAO;
     private ModuleManager moduleManager;
-    private CompletableFuture<List<MenuItem>> menuItemFuture;
-    private boolean isMenuItemsBeenFetched = false;
     private MetadataQueryService metadataQueryService;
 
-    public UIMenuManagementService(ModuleManager moduleManager) {
+    public UIMenuManagementService(ModuleManager moduleManager, 
CoreModuleConfig moduleConfig) {
         this.moduleManager = moduleManager;
-        this.menuItemFuture = new CompletableFuture<>();
+        this.menuItemCache = CacheBuilder.newBuilder()
+            .maximumSize(1)
+            .refreshAfterWrite(moduleConfig.getUiMenuRefreshInterval(), 
TimeUnit.SECONDS)

Review Comment:
   Why push first time late? This kind of mechanism usually is used for cold 
data, but menu is super hot. I think the timer should be up and running after 
initialized(if needed).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to