23 lines
661 B
Go
23 lines
661 B
Go
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
|
|
}
|