mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package reverseProxy
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"errors"
 | 
						|
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
						|
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						|
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
						|
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/schedulingconfigs"
 | 
						|
)
 | 
						|
 | 
						|
type SchedulingAction struct {
 | 
						|
	actionutils.ParentAction
 | 
						|
}
 | 
						|
 | 
						|
func (this *SchedulingAction) Init() {
 | 
						|
	this.FirstMenu("scheduling")
 | 
						|
}
 | 
						|
 | 
						|
func (this *SchedulingAction) RunGet(params struct {
 | 
						|
	ServerId int64
 | 
						|
}) {
 | 
						|
	reverseProxyResp, err := this.RPC().ServerRPC().FindAndInitServerReverseProxyConfig(this.AdminContext(), &pb.FindAndInitServerReverseProxyConfigRequest{ServerId: params.ServerId})
 | 
						|
	if err != nil {
 | 
						|
		this.ErrorPage(err)
 | 
						|
		return
 | 
						|
	}
 | 
						|
	var reverseProxy = serverconfigs.NewReverseProxyConfig()
 | 
						|
	err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
 | 
						|
	if err != nil {
 | 
						|
		this.ErrorPage(err)
 | 
						|
		return
 | 
						|
	}
 | 
						|
	this.Data["reverseProxyId"] = reverseProxy.Id
 | 
						|
 | 
						|
	schedulingCode := reverseProxy.FindSchedulingConfig().Code
 | 
						|
	schedulingMap := schedulingconfigs.FindSchedulingType(schedulingCode)
 | 
						|
	if schedulingMap == nil {
 | 
						|
		this.ErrorPage(errors.New("invalid scheduling code '" + schedulingCode + "'"))
 | 
						|
		return
 | 
						|
	}
 | 
						|
	this.Data["scheduling"] = schedulingMap
 | 
						|
 | 
						|
	this.Show()
 | 
						|
}
 |