package conf

import (
	"encoding/json"
	"git.quantgroup.cn/DevOps/enoch/service/log"
	"io/ioutil"
	"net/http"
)

var GlobalConfig = Config{}

func Load(denv string, didc string) {
	url := "http://apollo-" + denv + ".quantgroups.com/configfiles/real_json/enoch/" + didc + "/tech.config.json"
	resp, err := http.Get(url)
	defer func() { _ = resp.Body.Close() }()
	bytes, err := ioutil.ReadAll(resp.Body)
	err = json.Unmarshal(bytes, &GlobalConfig)
	GlobalConfig.Env = denv
	GlobalConfig.InfluxDb.Host = "http://172.20.6.33"
	if nil != err {
		logger.Error.Println(err)
	}
}
