fix(db): return error directly
This commit is contained in:
@@ -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() {
|
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.
|
||||||
@@ -86,11 +82,7 @@ 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user