Commit 39ae40ec authored by jingbo.wang's avatar jingbo.wang

dbinit

parent 0dce77d1
...@@ -85,7 +85,8 @@ func main() { ...@@ -85,7 +85,8 @@ func main() {
} }
}() }()
//更新连续查询 //初始化数据库(创建DB)
dao.DbInit()
//处理消息 //处理消息
handlerKafkaMsg() handlerKafkaMsg()
......
package dao
import (
"git.quantgroup.cn/DevOps/enoch/pkg/global"
"git.quantgroup.cn/DevOps/enoch/pkg/glog"
"github.com/influxdata/influxdb/client/v2"
"time"
)
func DbInit() {
config := client.HTTPConfig{
Addr: global.InfluxDbAddress,
Timeout: time.Second * 4,
}
c, err := client.NewHTTPClient(config)
if err != nil {
glog.Error("can not new influxdb http client")
return
}
//如果数据库不存在,创建数据库
if _, err := c.Query(client.Query{Command: "create database " + global.InfluxDbName}); err != nil {
glog.Error(err)
return
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment