fix(db): return error directly

This commit is contained in:
2026-06-04 13:16:04 +02:00
parent 89023b86ac
commit f4ab3093c3

View File

@@ -68,31 +68,23 @@ func (g *InfluxGateway) AddDatapoint(dp datapoint.DataPointInfo) error {
), ),
) )
// check if the number of point >= batchsize // if not ready, we are done
if g.batcher.Ready() { if g.batcher.Ready() {
// Send batch to influx DB
err := g.Flush()
if err != nil {
return err
}
}
return nil return nil
} }
// If ready, flush and return the result directly
return g.Flush()
}
// Flush sends the current batch of points to InfluxDB. // Flush sends the current batch of points to InfluxDB.
func (g *InfluxGateway) Flush() error { func (g *InfluxGateway) Flush() error {
// Send batch to influx DB // Send batch to influx DB
err := g.client.WritePoints(context.Background(), g.batcher.Emit()) err := g.client.WritePoints(context.Background(), g.batcher.Emit())
if err != nil {
return err return err
} }
return nil
}
// Close closes the InfluxGateway client. // Close closes the InfluxGateway client.
func (g *InfluxGateway) Close() error { func (g *InfluxGateway) Close() error {
return g.client.Close() return g.client.Close()