You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "KevinClair (via GitHub)" <gi...@apache.org> on 2023/02/01 05:53:10 UTC

[GitHub] [shenyu] KevinClair commented on a diff in pull request #4340: [ISSUE #4334] optimize shenyu-admin (#4334)

KevinClair commented on code in PR #4340:
URL: https://github.com/apache/shenyu/pull/4340#discussion_r1092783223


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/disruptor/subscriber/MetadataExecutorSubscriber.java:
##########
@@ -44,13 +44,11 @@ public DataType getType() {
 
     @Override
     public void executor(final Collection<MetaDataRegisterDTO> metaDataRegisterDTOList) {
-        metaDataRegisterDTOList.forEach(meta -> {
-            Optional.ofNullable(this.shenyuClientRegisterService.get(meta.getRpcType()))
-                    .ifPresent(shenyuClientRegisterService -> {
-                        synchronized (shenyuClientRegisterService) {
-                            shenyuClientRegisterService.register(meta);
-                        }
-                    });
-        });
+        metaDataRegisterDTOList.forEach(meta -> Optional.ofNullable(this.shenyuClientRegisterService.get(meta.getRpcType()))
+                .ifPresent(shenyuClientRegisterService -> {
+                    synchronized (shenyuClientRegisterService) {
+                        shenyuClientRegisterService.register(meta);
+                    }
+                }));

Review Comment:
   revert this.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/disruptor/subscriber/ApiDocExecutorSubscriber.java:
##########
@@ -44,13 +44,11 @@ public DataType getType() {
 
     @Override
     public void executor(final Collection<ApiDocRegisterDTO> dataList) {
-        dataList.forEach(apiDoc -> {
-            Optional.ofNullable(this.shenyuClientRegisterService.get(apiDoc.getRpcType()))
-                    .ifPresent(shenyuClientRegisterService -> {
-                        synchronized (shenyuClientRegisterService) {
-                            shenyuClientRegisterService.registerApiDoc(apiDoc);
-                        }
-                    });
-        });
+        dataList.forEach(apiDoc -> Optional.ofNullable(this.shenyuClientRegisterService.get(apiDoc.getRpcType()))
+                .ifPresent(shenyuClientRegisterService -> {
+                    synchronized (shenyuClientRegisterService) {
+                        shenyuClientRegisterService.registerApiDoc(apiDoc);
+                    }
+                }));

Review Comment:
   revert this.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java:
##########
@@ -83,16 +83,14 @@ private String update(final ApiDTO apiDTO) {
         final int updateRows = apiMapper.updateByPrimaryKeySelective(apiDO);
         if (CollectionUtils.isNotEmpty(apiDTO.getTagIds()) && updateRows > 0) {
             List<String> tagIds = apiDTO.getTagIds();
-            List<TagRelationDO> tags = Lists.newArrayList();
+            List<TagRelationDO> tags;
             Timestamp currentTime = new Timestamp(System.currentTimeMillis());
-            for (String tagId : tagIds) {
-                tags.add(TagRelationDO.builder()
-                        .id(UUIDUtils.getInstance().generateShortUuid())
-                        .apiId(apiDO.getId())
-                        .tagId(tagId)
-                        .dateUpdated(currentTime)
-                        .build());
-            }
+            tags = tagIds.stream().map(tagId -> TagRelationDO.builder()

Review Comment:
   merged with 86 lines of code.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImpl.java:
##########
@@ -88,11 +88,7 @@ public void addDocInfo(final String clusterName, final String docInfoJson, final
         }
         List<DocModule> docModules = docInfo.getDocModuleList();
         DOC_DEFINITION_MAP.put(docInfo.getTitle(), docInfo);
-        docModules.forEach(docModule -> {
-            docModule.getDocItems().forEach(docItem -> {
-                ITEM_DOC_MAP.put(docItem.getId(), docItem);
-            });
-        });
+        docModules.forEach(docModule -> docModule.getDocItems().forEach(docItem -> ITEM_DOC_MAP.put(docItem.getId(), docItem)));

Review Comment:
   revert.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java:
##########
@@ -110,17 +108,15 @@ private String create(final ApiDTO apiDTO) {
         final int insertRows = apiMapper.insertSelective(apiDO);
         if (CollectionUtils.isNotEmpty(apiDTO.getTagIds()) && insertRows > 0) {
             List<String> tagIds = apiDTO.getTagIds();
-            List<TagRelationDO> tags = Lists.newArrayList();
+            List<TagRelationDO> tags;
             Timestamp currentTime = new Timestamp(System.currentTimeMillis());
-            for (String tagId : tagIds) {
-                tags.add(TagRelationDO.builder()
-                        .id(UUIDUtils.getInstance().generateShortUuid())
-                        .apiId(apiDO.getId())
-                        .tagId(tagId)
-                        .dateCreated(currentTime)
-                        .dateUpdated(currentTime)
-                        .build());
-            }
+            tags = tagIds.stream().map(tagId -> TagRelationDO.builder()

Review Comment:
   merged with 111 lines of code.



-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org