refactored config names

This commit is contained in:
Paul 2019-06-15 13:55:48 +02:00
parent 4659714626
commit 0083207235
4 changed files with 17 additions and 14 deletions

View File

@ -8,10 +8,12 @@ xpath_base=.//pdv[@id='%s']/prix[@nom='%s']
# Comma separated values for pos and types # Comma separated values for pos and types
pos=50000007 pos=50000007
types=Gazole,SP95,SP98 types=Gazole,SP95,SP98
table=fuel_price
[influxdb]
# Influxdb settings # Influxdb settings
influx_host=host hostname=host
influx_db=me database=me
influx_port=8086 port=8086
influx_user=influx username=influx
influx_pass=password password=password

View File

@ -54,7 +54,7 @@ func main() {
fields := map[string]interface{}{"value": p.Amount} fields := map[string]interface{}{"value": p.Amount}
point, _ := client.NewPoint( point, _ := client.NewPoint(
fpc.InfluxTable, fpc.Table,
tags, tags,
fields, fields,
now, now,

View File

@ -33,15 +33,17 @@ func GetConfig(configfile string, fuelpricesconfig *FuelPricesConfig) error {
fpc.RemoteURL = fuelpricesSection.Key("remote_url").String() fpc.RemoteURL = fuelpricesSection.Key("remote_url").String()
fpc.RemoteFilename = fuelpricesSection.Key("remote_filename").String() fpc.RemoteFilename = fuelpricesSection.Key("remote_filename").String()
fpc.XPathBase = fuelpricesSection.Key("xpath_base").String() fpc.XPathBase = fuelpricesSection.Key("xpath_base").String()
fpc.InfluxHost = fuelpricesSection.Key("influx_host").String() fpc.Table = fuelpricesSection.Key("table").String()
fpc.InfluxPort, err = fuelpricesSection.Key("influx_port").Int()
influxdbSection := config.Section("influxdb")
fpc.InfluxHost = influxdbSection.Key("hostname").String()
fpc.InfluxPort, err = influxdbSection.Key("port").Int()
HandleError(err) HandleError(err)
fpc.InfluxUser = fuelpricesSection.Key("influx_user").String() fpc.InfluxUser = influxdbSection.Key("username").String()
fpc.InfluxPass = fuelpricesSection.Key("influx_pass").String() fpc.InfluxPass = influxdbSection.Key("password").String()
HandleError(err) HandleError(err)
fpc.InfluxDB = fuelpricesSection.Key("influx_db").String() fpc.InfluxDB = influxdbSection.Key("database").String()
fpc.InfluxTable = fuelpricesSection.Key("influx_table").String()
fpc.Pos = fuelpricesSection.Key("pos").Strings(",") fpc.Pos = fuelpricesSection.Key("pos").Strings(",")
fpc.Types = fuelpricesSection.Key("types").Strings(",") fpc.Types = fuelpricesSection.Key("types").Strings(",")

View File

@ -19,13 +19,12 @@ type FuelPricesConfig struct {
XPathBase string XPathBase string
Pos []string Pos []string
Types []string Types []string
TmpDir string Table string
InfluxHost string InfluxHost string
InfluxPort int InfluxPort int
InfluxUser string InfluxUser string
InfluxPass string InfluxPass string
InfluxDB string InfluxDB string
InfluxTable string
} }
// Price contains price of points of sale // Price contains price of points of sale