You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Both [asynchronous](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteAPI) or [synchronous](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteAPIBlocking) ways
39
-
-[How to writes](#writes)
39
+
-[How to writes](#writes)
40
40
- InfluxDB 2 API
41
41
- setup, ready, health
42
42
- authotizations, users, organizations
43
43
- buckets, delete
44
44
- ...
45
-
45
+
46
46
## Documentation
47
47
48
48
This section contains links to the client library documentation.
@@ -54,11 +54,11 @@ This section contains links to the client library documentation.
54
54
55
55
### Examples
56
56
57
-
Examples for basic writing and querying data are shown below in this document
57
+
Examples for basic writing and querying data are shown below in this document
Client offers two ways of writing, non-blocking and blocking.
166
+
Client offers two ways of writing, non-blocking and blocking.
167
167
168
-
### Non-blocking write client
168
+
### Non-blocking write client
169
169
Non-blocking write client uses implicit batching. Data are asynchronously
170
170
written to the underlying buffer and they are automatically sent to a server when the size of the write buffer reaches the batch size, default 5000, or the flush interval, default 1s, times out.
171
171
Writes are automatically retried on server back pressure.
172
172
173
-
This write client also offers synchronous blocking method to ensure that write buffer is flushed and all pending writes are finished,
173
+
This write client also offers synchronous blocking method to ensure that write buffer is flushed and all pending writes are finished,
174
174
see [Flush()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteAPI.Flush) method.
175
175
Always use [Close()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2#Client.Close) method of the client to stop all background processes.
176
-
176
+
177
177
Asynchronous write client is recommended for frequent periodic writes.
178
178
179
179
```go
@@ -183,13 +183,13 @@ import (
183
183
"fmt"
184
184
"math/rand"
185
185
"time"
186
-
186
+
187
187
"github.com/influxdata/influxdb-client-go/v2"
188
188
)
189
189
190
190
func main() {
191
191
// Create a new client using an InfluxDB server base URL and an authentication token
WriteAPI by default continues with retrying of failed writes.
225
+
WriteAPI by default continues with retrying of failed writes.
226
226
Retried are automatically writes that fail on a connection failure or when server returns response HTTP status code >= 429.
227
227
228
228
Retrying algorithm uses random exponential strategy to set retry time.
229
229
The delay forthe next retry attempt is a random valuein the interval _retryInterval * exponentialBase^(attempts)_ and _retryInterval * exponentialBase^(attempts+1)_.
230
-
If writes of batch repeatedly fails, WriteAPI continues with retrying until _maxRetries_ is reached or the overall retry time of batch exceeds _maxRetryTime_.
230
+
If writes of batch repeatedly fails, WriteAPI continues with retrying until _maxRetries_ is reached or the overall retry time of batch exceeds _maxRetryTime_.
231
231
232
232
The defaults parameters (part of the WriteOptions) are:
233
233
- _retryInterval_=5,000ms
234
234
- _exponentialBase_=2
235
235
- _maxRetryDelay_=125,000ms
236
236
- _maxRetries_=5
237
237
- _maxRetryTime_=180,000ms
238
-
238
+
239
239
Retry delays are by default randomly distributed within the ranges:
240
240
1. 5,000-10,000
241
241
1. 10,000-20,000
242
242
1. 20,000-40,000
243
243
1. 40,000-80,000
244
244
1. 80,000-125,000
245
-
246
-
Setting _retryInterval_ to 0 disables retry strategy and any failed write will discard the batch.
247
245
248
-
[WriteFailedCallback](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteFailedCallback) allows advanced controlling of retrying.
246
+
Setting _retryInterval_ to 0 disables retry strategy and any failed write will discard the batch.
247
+
248
+
[WriteFailedCallback](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteFailedCallback) allows advanced controlling of retrying.
249
249
It is synchronously notified incase async write fails.
250
-
It controls further batch handling by its return value. If it returns `true`, WriteAPI continues with retrying of writes of this batch. Returned `false` means the batch should be discarded.
250
+
It controls further batch handling by its return value. If it returns `true`, WriteAPI continues with retrying of writes of this batch. Returned `false` means the batch should be discarded.
251
251
252
252
### Reading async errors
253
253
WriteAPI automatically logs write errors. Use [Errors()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteAPI.Errors) method, which returns the channel for reading errors occuring during async writes, for writing write error to a custom target:
@@ -299,7 +299,7 @@ func main() {
299
299
}
300
300
```
301
301
302
-
### Blocking write client
302
+
### Blocking write client
303
303
Blocking write client writes given point(s) synchronously. It doesn't do implicit batching. Batch is created from given set of points.
304
304
Implicit batching can be enabled with `WriteAPIBlocking.EnableBatching()`.
305
305
@@ -350,9 +350,9 @@ func main() {
350
350
```
351
351
352
352
### Queries
353
-
Query client offers retrieving of query results to a parsed representation in a [QueryTableResult](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#QueryTableResult) or to a raw string.
353
+
Query client offers retrieving of query results to a parsed representation in a [QueryTableResult](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#QueryTableResult) or to a raw string.
354
354
355
-
### QueryTableResult
355
+
### QueryTableResult
356
356
QueryTableResult offers comfortable way how to deal with flux query CSV response. It parses CSV stream into FluxTableMetaData, FluxColumn and FluxRecord objects
357
357
for easy reading the result.
358
358
@@ -396,8 +396,8 @@ func main() {
396
396
```
397
397
398
398
### Raw
399
-
[QueryRaw()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#QueryAPI.QueryRaw) returns raw, unparsed, query result string and process it on your own. Returned csv format
400
-
can be controlled by the third parameter, query dialect.
399
+
[QueryRaw()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#QueryAPI.QueryRaw) returns raw, unparsed, query result string and process it on your own. Returned csv format
400
+
can be controlled by the third parameter, query dialect.
Client ensures that there is a single instance of each server API sub-client for the specific area. E.g. a single `WriteAPI` instance for each org/bucket pair,
531
+
Client ensures that there is a single instance of each server API sub-client for the specific area. E.g. a single `WriteAPI` instance for each org/bucket pair,
532
532
a single `QueryAPI` for each org.
533
533
534
534
Such a single API sub-client instance can be used concurrently:
@@ -587,10 +587,10 @@ func main() {
587
587
588
588
### Proxy and redirects
589
589
You can configure InfluxDB Go client behind a proxy in two ways:
590
-
1. Using environment variable
591
-
Set environment variable `HTTP_PROXY` (or `HTTPS_PROXY` based on the scheme of your server url).
590
+
1. Using environment variable
591
+
Set environment variable `HTTP_PROXY` (or `HTTPS_PROXY` based on the scheme of your server url).
592
592
e.g. (linux) `export HTTP_PROXY=http://my-proxy:8080` or in Go code `os.Setenv("HTTP_PROXY","http://my-proxy:8080")`
593
-
593
+
594
594
1. Configure `http.Client` to use proxy<br>
595
595
Create a custom `http.Client` with a proxy configuration:
596
596
```go
@@ -602,7 +602,7 @@ You can configure InfluxDB Go client behind a proxy in two ways:
There are three functions for checking whether a server is up and ready for communication:
@@ -630,23 +630,23 @@ There are three functions for checking whether a server is up and ready for comm
630
630
Only the [Ping()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2#Client.Ping) function works in InfluxDB Cloud server.
631
631
632
632
## InfluxDB 1.8 API compatibility
633
-
633
+
634
634
[InfluxDB 1.8.0 introduced forward compatibility APIs](https://docs.influxdata.com/influxdb/latest/tools/api/#influxdb-2-0-api-compatibility-endpoints) for InfluxDB 2.0. This allow you to easily move from InfluxDB 1.x to InfluxDB 2.0 Cloud or open source.
635
-
635
+
636
636
Client API usage differences summary:
637
637
1. Use the form `username:password` for an **authentication token**. Example: `my-user:my-password`. Use an empty string (`""`) if the server doesn't require authentication.
638
638
1. The organization parameter is not used. Use an empty string (`""`) where necessary.
639
639
1. Use the form `database/retention-policy` where a **bucket** is required. Skip retention policy if the default retention policy should be used. Examples: `telegraf/autogen`, `telegraf`.
640
-
640
+
641
641
The following forward compatible APIs are available:
642
-
642
+
643
643
| API | Endpoint | Description |
644
644
|:----------|:----------|:----------|
645
645
| [WriteAPI](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteAPI) (also [WriteAPIBlocking](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#WriteAPIBlocking))| [/api/v2/write](https://docs.influxdata.com/influxdb/v2.0/write-data/developer-tools/api/) | Write data to InfluxDB 1.8.0+ using the InfluxDB 2.0 API |
646
646
| [QueryAPI](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2/api#QueryAPI) | [/api/v2/query](https://docs.influxdata.com/influxdb/v2.0/query-data/execute-queries/influx-api/) | Query data in InfluxDB 1.8.0+ using the InfluxDB 2.0 API and [Flux](https://docs.influxdata.com/flux/latest/) endpoint should be enabled by the [`flux-enabled` option](https://docs.influxdata.com/influxdb/v1.8/administration/config/#flux-enabled-false)
647
-
| [Health()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2#Client.Health) | [/health](https://docs.influxdata.com/influxdb/v2.0/api/#tag/Health) | Check the health of your InfluxDB instance |
647
+
| [Health()](https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2#Client.Health) | [/health](https://docs.influxdata.com/influxdb/v2.0/api/#tag/Health) | Check the health of your InfluxDB instance |
0 commit comments