You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/09/29 02:54:17 UTC

[GitHub] [apisix-dashboard] starsz commented on a change in pull request #2152: feat: added dashboard backend api for apisix status summary

starsz commented on a change in pull request #2152:
URL: https://github.com/apache/apisix-dashboard/pull/2152#discussion_r718112966



##########
File path: api/internal/handler/dashboard/dashboard.go
##########
@@ -0,0 +1,258 @@
+/*
+ * 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 Dashboard
+
+import (
+	"github.com/apisix/manager-api/internal/conf"
+	"github.com/apisix/manager-api/internal/core/entity"
+	"github.com/apisix/manager-api/internal/core/store"
+	"github.com/apisix/manager-api/internal/handler"
+	"github.com/apisix/manager-api/internal/utils"
+	"github.com/gin-gonic/gin"
+	"github.com/shiningrush/droplet"
+	"github.com/shiningrush/droplet/wrapper"
+	wgin "github.com/shiningrush/droplet/wrapper/gin"
+	"reflect"
+	"sort"

Review comment:
       Need to group the import.
   https://github.com/uber-go/guide/blob/master/style.md#import-group-ordering

##########
File path: api/internal/core/entity/entity.go
##########
@@ -290,3 +290,14 @@ type PluginConfig struct {
 	Plugins map[string]interface{} `json:"plugins"`
 	Labels  map[string]string      `json:"labels,omitempty"`
 }
+
+type DashboardInfo struct {
+	RouteCnt        int64        `json:"router_cnt,omitempty"`
+	OnlineRouterCnt int64        `json:"online_router_cnt,omitempty"`
+	UpstreamCnt     int64        `json:"upstream_cnt,omitempty"`
+	ServiceCnt      int64        `json:"service_cnt,omitempty"`
+	CertificateCnt  int64        `json:"certificate_cnt,omitempty"`
+	Plugins         []string     `json:"plugins,omitempty"`
+	ApisixVersion   string       `json:"apisix_version,omitempty"`
+	ServerSummary   []*ServerInfo `json:"ServerSummary,omitempty"`

Review comment:
       Missing Dashboard version.

##########
File path: api/internal/handler/dashboard/dashboard.go
##########
@@ -0,0 +1,258 @@
+/*
+ * 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 Dashboard
+
+import (
+	"github.com/apisix/manager-api/internal/conf"
+	"github.com/apisix/manager-api/internal/core/entity"
+	"github.com/apisix/manager-api/internal/core/store"
+	"github.com/apisix/manager-api/internal/handler"
+	"github.com/apisix/manager-api/internal/utils"
+	"github.com/gin-gonic/gin"
+	"github.com/shiningrush/droplet"
+	"github.com/shiningrush/droplet/wrapper"
+	wgin "github.com/shiningrush/droplet/wrapper/gin"
+	"reflect"
+	"sort"
+)
+
+type Handler struct {
+	routeStore      store.Interface
+	upstreamStore   store.Interface
+	serverInfoStore store.Interface
+	serviceStore    store.Interface
+	sslStore        store.Interface
+}
+
+func NewHandler() (handler.RouteRegister, error) {
+	return &Handler{
+		routeStore:      store.GetStore(store.HubKeyRoute),
+		upstreamStore:   store.GetStore(store.HubKeyUpstream),
+		serverInfoStore: store.GetStore(store.HubKeyServerInfo),
+		serviceStore:    store.GetStore(store.HubKeyService),
+		sslStore:        store.GetStore(store.HubKeySsl),
+	}, nil
+}
+
+func (h *Handler) ApplyRoute(r *gin.Engine) {
+	r.GET("/apisix/admin/dashboard", wgin.Wraps(h.List,

Review comment:
       Maybe `/apisix/admin/overview`  is better ?
   You can refer other systems.




-- 
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@apisix.apache.org

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