Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
39ae40ec
Commit
39ae40ec
authored
Nov 14, 2019
by
jingbo.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbinit
parent
0dce77d1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
main.go
main.go
+2
-1
dbinit.go
pkg/dao/dbinit.go
+26
-0
No files found.
main.go
View file @
39ae40ec
...
...
@@ -85,7 +85,8 @@ func main() {
}
}()
//更新连续查询
//初始化数据库(创建DB)
dao
.
DbInit
()
//处理消息
handlerKafkaMsg
()
...
...
pkg/dao/dbinit.go
0 → 100644
View file @
39ae40ec
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
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment