30 lines
788 B
Go
30 lines
788 B
Go
// Package config 沿用 sample/server 的 BSM 配置加载与校验方式。
|
|
package config
|
|
|
|
import (
|
|
"net"
|
|
|
|
"git.apinb.com/bsm-sdk/core/conf"
|
|
)
|
|
|
|
// Spec 是 Platform API 的运行配置。
|
|
var Spec SrvConfig
|
|
|
|
// SrvConfig 与 sample/server 配置结构保持一致。
|
|
type SrvConfig struct {
|
|
conf.Base `yaml:",inline"`
|
|
Databases *conf.DBConf `yaml:"Databases"`
|
|
Rpc map[string]conf.RpcConf `yaml:"Rpc"`
|
|
Apm *conf.ApmConf `yaml:"APM"`
|
|
}
|
|
|
|
// New 初始化 BSM 配置并校验服务监听地址。
|
|
func New(srvKey string) {
|
|
conf.New(srvKey, &Spec)
|
|
Spec.Port = conf.CheckPort(Spec.Port)
|
|
Spec.BindIP = conf.CheckIP(Spec.BindIP)
|
|
Spec.Addr = net.JoinHostPort(Spec.BindIP, Spec.Port)
|
|
conf.NotNil(Spec.Service, Spec.Cache)
|
|
conf.PrintInfo(Spec.Addr)
|
|
}
|