updates on influxdb url

This commit is contained in:
Paul 2019-09-08 12:41:25 +02:00
parent 72e5b16b7a
commit 966a6355d9
5 changed files with 22 additions and 10 deletions

17
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": []
}
]
}

View File

@ -16,8 +16,7 @@ go build
```ini ```ini
[influxdb] [influxdb]
hostname=influxdb url=http://influxdb:8086/
port=8086
username=influxdb username=influxdb
password=password password=password
database=database database=database

View File

@ -37,8 +37,7 @@ func GetConfig(weatherconfig *WeatherConfig, configfile string) error {
} }
influxdbSection := config.Section("influxdb") influxdbSection := config.Section("influxdb")
wc.InfluxHost = influxdbSection.Key("hostname").MustString("localhost") wc.InfluxURL = influxdbSection.Key("url").MustString("http://localhost:8086")
wc.InfluxPort = influxdbSection.Key("port").MustInt(8086)
wc.InfluxUser = influxdbSection.Key("username").MustString("username") wc.InfluxUser = influxdbSection.Key("username").MustString("username")
wc.InfluxPass = influxdbSection.Key("password").MustString("password") wc.InfluxPass = influxdbSection.Key("password").MustString("password")
wc.InfluxDB = influxdbSection.Key("database").MustString("me") wc.InfluxDB = influxdbSection.Key("database").MustString("me")
@ -86,9 +85,8 @@ func FetchData(wc *WeatherConfig, city string) (Data, error) {
// SendToInflux sends time series data to influxdb // SendToInflux sends time series data to influxdb
func SendToInflux(wc *WeatherConfig, d Data) error { func SendToInflux(wc *WeatherConfig, d Data) error {
wc.InfluxAddr = fmt.Sprintf("http://%s:%d", wc.InfluxHost, wc.InfluxPort)
httpClient, err := client.NewHTTPClient(client.HTTPConfig{ httpClient, err := client.NewHTTPClient(client.HTTPConfig{
Addr: wc.InfluxAddr, Addr: wc.InfluxURL,
Username: wc.InfluxUser, Username: wc.InfluxUser,
Password: wc.InfluxPass, Password: wc.InfluxPass,
}) })

View File

@ -5,8 +5,7 @@ type WeatherConfig struct {
WeatherAppID string WeatherAppID string
WeatherCities []string WeatherCities []string
WeatherMeasurements []string WeatherMeasurements []string
InfluxHost string InfluxURL string
InfluxPort int
InfluxAddr string InfluxAddr string
InfluxUser string InfluxUser string
InfluxPass string InfluxPass string

View File

@ -1,6 +1,5 @@
[influxdb] [influxdb]
hostname=influxdb url=http://influxdb:8086/
port=8086
username=influxdb username=influxdb
password=password password=password
database=database database=database