新增测点配置
This commit is contained in:
22
core/influxdb/influxdb.go
Normal file
22
core/influxdb/influxdb.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package influxdb
|
||||
|
||||
import (
|
||||
"energy-management-system/global"
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
)
|
||||
|
||||
func InitInFluxDb() {
|
||||
|
||||
// Create a new client using an InfluxDB server base URL and an authentication token
|
||||
client := influxdb2.NewClient(global.AppConf.InFluxDb.Host, global.AppConf.InFluxDb.Token)
|
||||
// Use blocking write client for writes to desired bucket
|
||||
|
||||
//获取非阻塞式写入对象
|
||||
//writeAPI = client.WriteAPI("my-org", "my-bucket")
|
||||
//writeAPI := client.WriteAPIBlocking("my-org", "my-bucket")
|
||||
|
||||
//获取阻塞式写入对象
|
||||
//writeBlockingAPI := client.WriteAPIBlocking("iuu", "iuu-bucket")
|
||||
|
||||
global.InFluxDb = client
|
||||
}
|
||||
Reference in New Issue
Block a user