Files
EdgeAdmin/internal/web/actions/default/servers/components/cache/test.go

44 lines
1.1 KiB
Go
Raw Normal View History

2020-10-02 17:22:24 +08:00
package cache
2020-10-04 14:27:05 +08:00
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
2020-10-04 16:09:50 +08:00
"github.com/iwind/TeaGo/types"
2020-10-04 14:27:05 +08:00
)
2020-10-02 17:22:24 +08:00
type TestAction struct {
actionutils.ParentAction
}
func (this *TestAction) Init() {
2020-10-04 14:27:05 +08:00
this.Nav("", "", "test")
2020-10-02 17:22:24 +08:00
}
2020-12-17 17:35:38 +08:00
func (this *TestAction) RunGet(params struct {
CachePolicyId int64
}) {
2020-10-04 16:09:50 +08:00
// 默认的集群ID
cookie, err := this.Request.Cookie("cache_cluster_id")
if cookie != nil && err == nil {
this.Data["clusterId"] = types.Int64(cookie.Value)
}
2020-10-04 14:27:05 +08:00
// 集群列表
2020-12-17 17:35:38 +08:00
clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId})
2020-10-04 14:27:05 +08:00
if err != nil {
this.ErrorPage(err)
return
}
clusterMaps := []maps.Map{}
2020-12-17 17:35:38 +08:00
for _, cluster := range clustersResp.NodeClusters {
2020-10-04 14:27:05 +08:00
clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.Id,
"name": cluster.Name,
})
}
this.Data["clusters"] = clusterMaps
2020-10-02 17:22:24 +08:00
this.Show()
}