30 lines
759 B
Go
30 lines
759 B
Go
// Package config 沿用 sample/server 的 BSM 运行配置与地址校验。
|
|
package config
|
|
|
|
import (
|
|
"net"
|
|
|
|
"git.apinb.com/bsm-sdk/core/conf"
|
|
)
|
|
|
|
// Spec 是 Worker 运行配置。
|
|
var Spec SrvConfig
|
|
|
|
// SrvConfig 保持与 API 进程相同的 BSM 配置结构。
|
|
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 初始化 Worker 配置。
|
|
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)
|
|
}
|