robocanic commented on code in PR #1487:
URL: https://github.com/apache/dubbo-admin/pull/1487#discussion_r3487737875


##########
api/mesh/v1alpha1/k8s_event.proto:
##########
@@ -0,0 +1,38 @@
+syntax = "proto3";
+
+package dubbo.mesh.v1alpha1;
+
+option go_package = "github.com/apache/dubbo-admin/api/mesh/v1alpha1";
+
+import "api/mesh/options.proto";
+
+message K8sEvent {

Review Comment:
   Question: PlatformEvent为什么没有proto定义?



##########
api/mesh/v1alpha1/k8s_event.go:
##########


Review Comment:
   Suggestion: 
这个文件应该要由插件自动生成的,见:[Resource的定义与更新](https://github.com/apache/dubbo-admin/wiki/%E6%96%B0%E7%89%88Dubbo-Admin%E5%BC%80%E5%8F%91%E8%80%85%E6%8C%87%E5%8D%97#resource%E7%9A%84%E5%AE%9A%E4%B9%89%E5%92%8C%E6%9B%B4%E6%96%B0)



##########
pkg/console/service/event.go:
##########
@@ -0,0 +1,333 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+       "sort"
+       "strings"
+       "time"
+
+       consolectx "github.com/apache/dubbo-admin/pkg/console/context"
+       "github.com/apache/dubbo-admin/pkg/console/model"
+       "github.com/apache/dubbo-admin/pkg/core/manager"
+       meshresource 
"github.com/apache/dubbo-admin/pkg/core/resource/apis/mesh/v1alpha1"
+       coremodel "github.com/apache/dubbo-admin/pkg/core/resource/model"
+       "github.com/apache/dubbo-admin/pkg/core/store/index"
+)
+
+func ListApplicationEvents(ctx consolectx.Context, req *model.EventQueryReq) 
(*model.EventListResp, error) {
+       k8sEvents, err := manager.ListByIndexes[*meshresource.K8sEventResource](
+               ctx.ResourceManager(),
+               meshresource.K8sEventKind,
+               buildApplicationK8sConditions(req),
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       platformEvents, err := 
manager.ListByIndexes[*meshresource.PlatformEventResource](
+               ctx.ResourceManager(),
+               meshresource.PlatformEventKind,
+               buildApplicationPlatformConditions(req),
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       return buildEventListResp(req.PageReq, 
toApplicationEventEntries(k8sEvents, platformEvents)), nil
+}
+
+func ListInstanceEvents(ctx consolectx.Context, req *model.EventQueryReq) 
(*model.EventListResp, error) {
+       k8sEvents, err := manager.ListByIndexes[*meshresource.K8sEventResource](
+               ctx.ResourceManager(),
+               meshresource.K8sEventKind,
+               []index.IndexCondition{
+                       {IndexName: index.ByMeshIndex, Value: req.Mesh, 
Operator: index.Equals},
+               },
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       platformEvents, err := 
manager.ListByIndexes[*meshresource.PlatformEventResource](
+               ctx.ResourceManager(),
+               meshresource.PlatformEventKind,
+               []index.IndexCondition{
+                       {IndexName: index.ByMeshIndex, Value: req.Mesh, 
Operator: index.Equals},
+               },
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       return buildEventListResp(req.PageReq, toInstanceEventEntries(req, 
k8sEvents, platformEvents)), nil
+}
+
+func ListServiceEvents(ctx consolectx.Context, req *model.EventQueryReq) 
(*model.EventListResp, error) {
+       k8sEvents, err := manager.ListByIndexes[*meshresource.K8sEventResource](
+               ctx.ResourceManager(),
+               meshresource.K8sEventKind,
+               buildServiceK8sConditions(req),
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       platformEvents, err := 
manager.ListByIndexes[*meshresource.PlatformEventResource](
+               ctx.ResourceManager(),
+               meshresource.PlatformEventKind,
+               buildServicePlatformConditions(req),
+       )
+       if err != nil {
+               return nil, err
+       }
+
+       return buildEventListResp(req.PageReq, toServiceEventEntries(k8sEvents, 
platformEvents)), nil
+}
+
+type eventEntry struct {
+       timeValue time.Time
+       event     *model.EventItem
+}
+
+func buildApplicationK8sConditions(req *model.EventQueryReq) 
[]index.IndexCondition {
+       conditions := []index.IndexCondition{

Review Comment:
   Correction: 
这里的AppName参数需要前端必传,不传需要抛异常,不然这里的过滤条件太宽泛了,会把整个mesh的所有事件全部捞出来。下面的过滤条件也是一样



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to