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"
	"gitlink.org.cn/cloudream/jcs-pub/coordinator/internal/db"
	"gitlink.org.cn/cloudream/jcs-pub/coordinator/internal/ticktock"
)

type Config struct {
	Logger   log.Config      `json:"logger"`
	DB       db.Config       `json:"db"`
	RabbitMQ mq.Config       `json:"rabbitMQ"`
	TickTock ticktock.Config `json:"tickTock"`
}

var cfg Config

func Init(path string) error {
	if path == "" {
		return c.DefaultLoad("coordinator", &cfg)
	}

	return c.Load(path, &cfg)
}

func Cfg() *Config {
	return &cfg
}
