Hi there,
I am using the influxdb v2 client to batch points and send it. I have a flush function in which I write the batchpoints, and then start using a new batchpoints struct. Is there a better way to achieve this ? I don’t see any clearPoints API or anything like that.
My research in github did lead me to this - https://github.com/influxdata/influxdb/pull/4387#r41890634. So this issue was apparently discussed but nothing came out of it.
This is my code -
// helper function to return new batch points for every batch
func getNewBatch(db, precision string) (influxdb.BatchPoints, error) {
return influxdb.NewBatchPoints(influxdb.BatchPointsConfig{
Database: db,
Precision: precision,
})
}
func (i *influxDBOutput) Flush() error {
// Flushing the current batch
err := i.client.Write(i.batchPts)
if err != nil {
return err
}
// Creating new batch
bp, err := getNewBatch(i.database, i.precision)
if err != nil {
return err
}
i.batchPts = bp
return nil
}
The Flush() function is called from a different part of the code.