From f4ab3093c3c5d4f58ffdefb5e611abd573347797 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Thu, 4 Jun 2026 13:16:04 +0200 Subject: [PATCH] fix(db): return error directly --- db/src/influx/influx.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/db/src/influx/influx.go b/db/src/influx/influx.go index 5823158..d9a77e1 100644 --- a/db/src/influx/influx.go +++ b/db/src/influx/influx.go @@ -68,17 +68,13 @@ 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() { - // 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. @@ -86,11 +82,7 @@ func (g *InfluxGateway) Flush() error { // Send batch to influx DB err := g.client.WritePoints(context.Background(), g.batcher.Emit()) - if err != nil { - return err - } - - return nil + return err } // Close closes the InfluxGateway client.