diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0ec831d --- /dev/null +++ b/.vscode/launch.json @@ -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": [] + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 7d3b4b9..ae771bb 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ go build ```ini [influxdb] -hostname=influxdb -port=8086 +url=http://influxdb:8086/ username=influxdb password=password database=database diff --git a/functions.go b/functions.go index cee7429..ad37a82 100644 --- a/functions.go +++ b/functions.go @@ -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, }) diff --git a/types.go b/types.go index f431ee6..c4ed14a 100644 --- a/types.go +++ b/types.go @@ -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 diff --git a/weather.ini.sample b/weather.ini.sample index c6352bc..8aa96d1 100644 --- a/weather.ini.sample +++ b/weather.ini.sample @@ -1,6 +1,5 @@ [influxdb] -hostname=influxdb -port=8086 +url=http://influxdb:8086/ username=influxdb password=password database=database