influxdata / influxdb-client-go

InfluxDB 2 Go Client
MIT License
609 stars 116 forks source link

Documentation required on how to enablebatching on WriteAPIBlocking #407

Closed harishav closed 2 months ago

harishav commented 2 months ago

Hi Team,

We are using WriteAPIBlocking for our usecase and the initializing logic goes as below.

client := influxdb2.NewClient(tsDBHost, tsToken)
writeAPIClient := client.WriteAPIBlocking(tsDBOrg, tsDBBucket)

Now i wanted to enable batching, as per docs i need to do something like below, writeAPIClient.EnableBatching()

And then to control the batchSize, its mentioned to specify write.Options(), but we couldn't understand on how to pass the writeOptions and couldn't find any example around that. Can you help on how to enable batching passing the required options ??

Thanks!

bednar commented 2 months ago

Hi @harishav,

batching is enabled by default, the writeAPIClient.EnableBatching() is unnecessary. You can configure batch size by:

 client := influxdb2.NewClientWithOptions("http://localhost:8086", "my-token",
        influxdb2.DefaultOptions().SetBatchSize(20))

For more info see:

Best Regards