35 lines
926 B
Go
35 lines
926 B
Go
package config
|
|
|
|
import (
|
|
log "gitlink.org.cn/cloudream/common/pkgs/logger"
|
|
"gitlink.org.cn/cloudream/common/pkgs/mq"
|
|
c "gitlink.org.cn/cloudream/common/utils/config"
|
|
stgglb "gitlink.org.cn/cloudream/jcs-pub/common/globals"
|
|
"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/connectivity"
|
|
"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/grpc"
|
|
cortypes "gitlink.org.cn/cloudream/jcs-pub/coordinator/types"
|
|
)
|
|
|
|
type Config struct {
|
|
ID cortypes.HubID `json:"id"`
|
|
Local stgglb.LocalMachineInfo `json:"local"`
|
|
GRPC *grpc.Config `json:"grpc"`
|
|
Logger log.Config `json:"logger"`
|
|
RabbitMQ mq.Config `json:"rabbitMQ"`
|
|
Connectivity connectivity.Config `json:"connectivity"`
|
|
}
|
|
|
|
var cfg Config
|
|
|
|
func Init(path string) error {
|
|
if path == "" {
|
|
return c.DefaultLoad("hub", &cfg)
|
|
}
|
|
|
|
return c.Load(path, &cfg)
|
|
}
|
|
|
|
func Cfg() *Config {
|
|
return &cfg
|
|
}
|