Do not fail Connect() in influxdb output when db creation fails

Fixes #304
This commit is contained in:
Cameron Sparr 2015-10-22 11:14:10 -06:00
parent eb0a19062e
commit c8852339c9
1 changed files with 2 additions and 6 deletions

View File

@ -78,24 +78,20 @@ func (i *InfluxDB) Connect() error {
conns = append(conns, c)
}
// This will get set to nil if a successful connection is made
err := errors.New("Could not create database on any server")
for _, conn := range conns {
_, e := conn.Query(client.Query{
Command: fmt.Sprintf("CREATE DATABASE %s", i.Database),
})
if e != nil && !strings.Contains(e.Error(), "database already exists") {
log.Println("ERROR: " + e.Error())
log.Println("Database creation failed: " + e.Error())
} else {
err = nil
break
}
}
i.conns = conns
return err
return nil
}
func (i *InfluxDB) Close() error {