mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 07:10:27 +08:00
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package cache
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/cache/cacheutils"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
type PolicyAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *PolicyAction) Init() {
|
|
this.Nav("", "", "index")
|
|
}
|
|
|
|
func (this *PolicyAction) RunGet(params struct {
|
|
CachePolicyId int64
|
|
}) {
|
|
cachePolicy, err := cacheutils.FindCachePolicy(this.Parent(), params.CachePolicyId)
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
this.Data["cachePolicy"] = cachePolicy
|
|
|
|
this.Data["typeName"] = serverconfigs.FindCachePolicyStorageName(cachePolicy.Type)
|
|
|
|
// 正在使用此策略的集群
|
|
clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
clusterMaps := []maps.Map{}
|
|
for _, cluster := range clustersResp.NodeClusters {
|
|
clusterMaps = append(clusterMaps, maps.Map{
|
|
"id": cluster.Id,
|
|
"name": cluster.Name,
|
|
})
|
|
}
|
|
this.Data["clusters"] = clusterMaps
|
|
|
|
this.Show()
|
|
}
|