service.go 1.6 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
package service

import "encoding/json"

type Simple struct {
	Name        string `json:"name"`
	Driver      string `json:"driver"`
	DriverTitle string `json:"driverTitle"`
	Type        string `json:"type"`
}

type Service struct {
	Simple

	Desc        string `json:"desc"`
	IsDefault   bool   `json:"isDefault"`
	HealthCheck bool   `json:"healthCheck"`
	UpdateTime  string `json:"updateTime"`
	CreateTime         string `json:"createTime"`
}

type Info struct {
	*Service
	Config             string `json:"config"`
	ClusterConfig      string `json:"-"`
	ClusterConfigObj map[string]string `json:"clusterConfig"`
	HealthCheckPath    string `json:"healthCheckPath"`
	HealthCheckPeriod  int    `json:"healthCheckPeriod"`
	HealthCheckCode    string `json:"healthCheckCode"`
	HealthCheckTimeOut int    `json:"healthCheckTimeOut"`
}

func (i *Info) Decode()  {
	json.Unmarshal([]byte(i.ClusterConfig),&i.ClusterConfigObj)
}

type AddParam struct {
	Name               string `opt:"name,require"`
	Driver             string `opt:"driver" default:"static"`
	Desc               string `opt:"desc"`
	Config             string `opt:"config"`
	ClusterConfig      string `opt:"clusterConfig"`
	//ClusterConfigObj map[string]string `json:"clusterConfig"`
	HealthCheck        bool   `opt:"healthCheck" default:"false"`
	HealthCheckPath    string `opt:"healthCheckPath"`
	HealthCheckPeriod  int    `opt:"healthCheckPeriod" default:"5" min:"1" max:"60"`
	HealthCheckCode    string `opt:"healthCheckCode" default:"200"`
	HealthCheckTimeOut int    `opt:"healthCheckTimeOut" default:"300" max:"5000" min:"0"`
}