gateway.go 2.2 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3
package gateway

import (
Y
Your Name 已提交
4 5
	v "github.com/eolinker/goku-api-gateway/common/version"
	console_sqlite3 "github.com/eolinker/goku-api-gateway/server/dao/console-sqlite3"
E
eoLinker API Management 已提交
6 7
)

Y
Your Name 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//BaseGatewayInfo 网关基本配置
type BaseGatewayInfo struct {
	NodeCount      int    `json:"nodeCount"`
	NodeStartCount int    `json:"nodeStartCount"`
	NodeStopCount  int    `json:"nodeStopCount"`
	ProjectCount   int    `json:"projectCount"`
	APICount       int    `json:"apiCount"`
	StrategyCount  int    `json:"strategyCount"`
	PluginCount    int    `json:"pluginCount"`
	ClusterCount   int    `json:"clusterCount"`
	Version        string `json:"version"`
}

//SystemInfo 系统配置
type SystemInfo struct {
	BaseInfo BaseGatewayInfo `json:"baseInfo"`
}

Y
Your Name 已提交
26
//GetGatewayConfig 获取网关配置
E
eoLinker API Management 已提交
27
func GetGatewayConfig() (map[string]interface{}, error) {
Y
Your Name 已提交
28
	return console_sqlite3.GetGatewayConfig()
E
eoLinker API Management 已提交
29 30
}

Y
Your Name 已提交
31
//EditGatewayBaseConfig 编辑网关基本配置
E
eoLinker API Management 已提交
32
func EditGatewayBaseConfig(successCode string, nodeUpdatePeriod, monitorUpdatePeriod, timeout int) (bool, string, error) {
Y
Your Name 已提交
33
	flag, result, err := console_sqlite3.EditGatewayBaseConfig(successCode, nodeUpdatePeriod, monitorUpdatePeriod, timeout)
E
eoLinker API Management 已提交
34 35 36
	return flag, result, err
}

Y
Your Name 已提交
37
//EditGatewayAlarmConfig 编辑网关告警配置
E
eoLinker API Management 已提交
38
func EditGatewayAlarmConfig(apiAlertInfo, sender, senderPassword, smtpAddress string, alertStatus, smtpPort, smtpProtocol int) (bool, string, error) {
Y
Your Name 已提交
39 40
	flag, result, err := console_sqlite3.EditGatewayAlarmConfig(apiAlertInfo, sender, senderPassword, smtpAddress, alertStatus, smtpPort, smtpProtocol)

E
eoLinker API Management 已提交
41 42
	return flag, result, err
}
Y
Your Name 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

//GetGatewayMonitorSummaryByPeriod 获取监控summary
func GetGatewayMonitorSummaryByPeriod() (bool, *SystemInfo, error) {

	nodeStartCount, nodeStopCount, projectCount, apiCount, strategyCount, e := console_sqlite3.GetGatewayInfo()
	if e != nil {
		return false, nil, e
	}
	info := new(SystemInfo)
	info.BaseInfo.PluginCount = console_sqlite3.GetPluginCount()
	info.BaseInfo.NodeCount = nodeStartCount + nodeStopCount
	info.BaseInfo.ProjectCount = projectCount
	info.BaseInfo.APICount = apiCount
	info.BaseInfo.StrategyCount = strategyCount
	info.BaseInfo.Version = v.Version
	info.BaseInfo.ClusterCount = console_sqlite3.GetClusterCount()

	return true, info, nil

}