param.go 1.5 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4
package balance

import (
	"encoding/json"
黄孟柱 已提交
5
	entity "github.com/eolinker/goku-api-gateway/server/entity/balance-entity-service"
E
eoLinker API Management 已提交
6 7
)

Y
Your Name 已提交
8
//Param param
E
eoLinker API Management 已提交
9
type Param struct {
Y
Your Name 已提交
10 11 12 13
	Name          string `opt:"balanceName,require"`
	ServiceName   string `opt:"serviceName,require"`
	AppName       string `opt:"appName"`
	Static        string `opt:"static"`
E
eoLinker API Management 已提交
14
	StaticCluster string `opt:"staticCluster"`
Y
Your Name 已提交
15
	Desc          string `opt:"balanceDesc"`
E
eoLinker API Management 已提交
16 17
}

Y
Your Name 已提交
18
//Info info
E
eoLinker API Management 已提交
19
type Info struct {
Y
Your Name 已提交
20 21 22 23 24 25 26 27 28 29
	Name          string            `json:"balanceName"`
	ServiceName   string            `json:"serviceName"`
	ServiceType   string            `json:"serviceType"`
	ServiceDriver string            `json:"serviceDriver"`
	AppName       string            `json:"appName"`
	Static        string            `json:"static"`
	StaticCluster map[string]string `json:"staticCluster"`
	Desc          string            `json:"balanceDesc"`
	CreateTime    string            `json:"createTime"`
	UpdateTime    string            `json:"updateTime"`
E
eoLinker API Management 已提交
30 31
}

Y
Your Name 已提交
32
//ReadInfo 读取负载配置
E
eoLinker API Management 已提交
33
func ReadInfo(balance *entity.Balance) *Info {
Y
Your Name 已提交
34
	info := &Info{
E
eoLinker API Management 已提交
35 36 37 38
		Name:          balance.Name,
		ServiceName:   balance.ServiceName,
		ServiceType:   balance.ServiceType,
		ServiceDriver: balance.ServiceDriver,
Y
Your Name 已提交
39
		AppName:       balance.AppName,
E
eoLinker API Management 已提交
40 41 42 43 44 45
		Static:        balance.Static,
		StaticCluster: nil,
		Desc:          balance.Desc,
		CreateTime:    balance.CreateTime,
		UpdateTime:    balance.UpdateTime,
	}
Y
Your Name 已提交
46
	json.Unmarshal([]byte(balance.StaticCluster), &info.StaticCluster)
E
eoLinker API Management 已提交
47
	return info
Y
Your Name 已提交
48
}