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
[influxdb]
hostname=influxdb
port=8086
url=http://influxdb:8086/
username=influxdb
password=password
database=database

View File

@ -37,8 +37,7 @@ func GetConfig(weatherconfig *WeatherConfig, configfile string) error {
}
influxdbSection := config.Section("influxdb")
wc.InfluxHost = influxdbSection.Key("hostname").MustString("localhost")
wc.InfluxPort = influxdbSection.Key("port").MustInt(8086)
wc.InfluxURL = influxdbSection.Key("url").MustString("http://localhost:8086")
wc.InfluxUser = influxdbSection.Key("username").MustString("username")
wc.InfluxPass = influxdbSection.Key("password").MustString("password")
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
func SendToInflux(wc *WeatherConfig, d Data) error {
wc.InfluxAddr = fmt.Sprintf("http://%s:%d", wc.InfluxHost, wc.InfluxPort)
httpClient, err := client.NewHTTPClient(client.HTTPConfig{
Addr: wc.InfluxAddr,
Addr: wc.InfluxURL,
Username: wc.InfluxUser,
Password: wc.InfluxPass,
})

View File

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

View File

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