Skip to content

Commit 095ca25

Browse files
committed
docs: Adding clarification that server URL needs to be base URL
1 parent 2daff58 commit 095ca25

File tree

5 files changed

+40
-31
lines changed

5 files changed

+40
-31
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.1.0 [in progress]
2+
### Documentation
3+
1. [#189](https://github.com/influxdata/influxdb-client-go/pull/189) Added clarification that server URL has to be the InfluxDB server base URL to API docs and all examples.
4+
5+
16
## 2.0.1 [2020-08-14]
27
### Bug fixes
38
1. [#187](https://github.com/influxdata/influxdb-client-go/pull/187) Properly updated library for new major version.

README.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,18 @@ import (
7171
)
7272

7373
func main() {
74-
// create new client with default option for server url authenticate by token
74+
// Create a new client using an InfluxDB server base URL and an authentication token
7575
client := influxdb2.NewClient("http://localhost:9999", "my-token")
76-
// user blocking write client for writes to desired bucket
76+
// Use blocking write client for writes to desired bucket
7777
writeAPI := client.WriteAPIBlocking("my-org", "my-bucket")
78-
// create point using full params constructor
78+
// Create point using full params constructor
7979
p := influxdb2.NewPoint("stat",
8080
map[string]string{"unit": "temperature"},
8181
map[string]interface{}{"avg": 24.5, "max": 45},
8282
time.Now())
8383
// write point immediately
8484
writeAPI.WritePoint(context.Background(), p)
85-
// create point using fluent style
85+
// Create point using fluent style
8686
p = influxdb2.NewPointWithMeasurement("stat").
8787
AddTag("unit", "temperature").
8888
AddField("avg", 23.2).
@@ -94,9 +94,9 @@ func main() {
9494
line := fmt.Sprintf("stat,unit=temperature avg=%f,max=%f", 23.5, 45.0)
9595
writeAPI.WriteRecord(context.Background(), line)
9696

97-
// get query client
97+
// Get query client
9898
queryAPI := client.QueryAPI("my-org")
99-
// get parser flux query result
99+
// Get parser flux query result
100100
result, err := queryAPI.Query(context.Background(), `from(bucket:"my-bucket")|> range(start: -1h) |> filter(fn: (r) => r._measurement == "stat")`)
101101
if err == nil {
102102
// Use Next() to iterate over query result lines
@@ -140,7 +140,7 @@ Client offers two ways of writing, non-blocking and blocking.
140140

141141
### Non-blocking write client
142142
Non-blocking write client uses implicit batching. Data are asynchronously
143-
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 1000, or the flush interval, default 1s, times out.
143+
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.
144144
Writes are automatically retried on server back pressure.
145145

146146
This write client also offers synchronous blocking method to ensure that write buffer is flushed and all pending writes are finished,
@@ -161,7 +161,8 @@ import (
161161
)
162162

163163
func main() {
164-
// Create client and set batch size to 20
164+
// Create a new client using an InfluxDB server base URL and an authentication token
165+
// and set batch size to 20
165166
client := influxdb2.NewClientWithOptions("http://localhost:9999", "my-token",
166167
influxdb2.DefaultOptions().SetBatchSize(20))
167168
// Get non-blocking write client
@@ -210,7 +211,7 @@ import (
210211
)
211212

212213
func main() {
213-
// Create client
214+
// Create a new client using an InfluxDB server base URL and an authentication token
214215
client := influxdb2.NewClient("http://localhost:9999", "my-token")
215216
// Get non-blocking write client
216217
writeAPI := client.WriteAPI("my-org", "my-bucket")
@@ -261,7 +262,7 @@ import (
261262
)
262263

263264
func main() {
264-
// Create client
265+
// Create a new client using an InfluxDB server base URL and an authentication token
265266
client := influxdb2.NewClient("http://localhost:9999", "my-token")
266267
// Get blocking write client
267268
writeAPI := client.WriteAPIBlocking("my-org","my-bucket")
@@ -312,7 +313,7 @@ import (
312313
)
313314

314315
func main() {
315-
// Create client
316+
// Create a new client using an InfluxDB server base URL and an authentication token
316317
client := influxdb2.NewClient("http://localhost:9999", "my-token")
317318
// Get query client
318319
queryAPI := client.QueryAPI("my-org")
@@ -355,7 +356,7 @@ import (
355356
)
356357

357358
func main() {
358-
// Create client
359+
// Create a new client using an InfluxDB server base URL and an authentication token
359360
client := influxdb2.NewClient("http://localhost:9999", "my-token")
360361
// Get query client
361362
queryAPI := client.QueryAPI("my-org")
@@ -407,8 +408,8 @@ import (
407408
func main() {
408409
userName := "my-user"
409410
password := "my-password"
410-
// Create a client
411-
// Supply a string in the form: "username:password" as a token. Set empty value for an unauthenticated server
411+
// Create a new client using an InfluxDB server base URL and an authentication token
412+
// For authentication token supply a string in the form: "username:password" as a token. Set empty value for an unauthenticated server
412413
client := influxdb2.NewClient("http://localhost:8086", fmt.Sprintf("%s:%s",userName, password))
413414
// Get the blocking write client
414415
// Supply a string in the form database/retention-policy as a bucket. Skip retention policy for the default one, use just a database name (without the slash character)

api/examples_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func ExampleBucketsAPI() {
16-
// Create influxdb client
16+
// Create a new client using an InfluxDB server base URL and an authentication token
1717
client := influxdb2.NewClient("http://localhost:9999", "my-token")
1818

1919
ctx := context.Background()
@@ -44,7 +44,7 @@ func ExampleBucketsAPI() {
4444
}
4545

4646
func ExampleWriteAPIBlocking() {
47-
// Create client
47+
// Create a new client using an InfluxDB server base URL and an authentication token
4848
client := influxdb2.NewClient("http://localhost:9999", "my-token")
4949
// Get blocking write client
5050
writeAPI := client.WriteAPIBlocking("my-org", "my-bucket")
@@ -77,7 +77,7 @@ func ExampleWriteAPIBlocking() {
7777
}
7878

7979
func ExampleWriteAPI() {
80-
// Create client
80+
// Create a new client using an InfluxDB server base URL and an authentication token
8181
client := influxdb2.NewClient("http://localhost:9999", "my-token")
8282
// Get non-blocking write client
8383
writeAPI := client.WriteAPI("my-org", "my-bucket")
@@ -109,7 +109,7 @@ func ExampleWriteAPI() {
109109
}
110110

111111
func ExampleWriteAPI_errors() {
112-
// Create client
112+
// Create a new client using an InfluxDB server base URL and an authentication token
113113
client := influxdb2.NewClient("http://localhost:9999", "my-token")
114114
// Get non-blocking write client
115115
writeAPI := client.WriteAPI("my-org", "my-bucket")
@@ -144,7 +144,7 @@ func ExampleWriteAPI_errors() {
144144
}
145145

146146
func ExampleQueryAPI_query() {
147-
// Create client
147+
// Create a new client using an InfluxDB server base URL and an authentication token
148148
client := influxdb2.NewClient("http://localhost:9999", "my-token")
149149
// Get query client
150150
queryAPI := client.QueryAPI("my-org")
@@ -172,7 +172,7 @@ func ExampleQueryAPI_query() {
172172
}
173173

174174
func ExampleQueryAPI_queryRaw() {
175-
// Create client
175+
// Create a new client using an InfluxDB server base URL and an authentication token
176176
client := influxdb2.NewClient("http://localhost:9999", "my-token")
177177
// Get query client
178178
queryAPI := client.QueryAPI("my-org")
@@ -190,7 +190,7 @@ func ExampleQueryAPI_queryRaw() {
190190
}
191191

192192
func ExampleOrganizationsAPI() {
193-
// Create influxdb client
193+
// Create a new client using an InfluxDB server base URL and an authentication token
194194
client := influxdb2.NewClient("http://localhost:9999", "my-token")
195195

196196
// Get Organizations API client
@@ -238,7 +238,7 @@ func ExampleOrganizationsAPI() {
238238
}
239239

240240
func ExampleAuthorizationsAPI() {
241-
// Create influxdb client
241+
// Create a new client using an InfluxDB server base URL and an authentication token
242242
client := influxdb2.NewClient("http://localhost:9999", "my-token")
243243

244244
// Find user to grant permission
@@ -292,7 +292,7 @@ func ExampleAuthorizationsAPI() {
292292
}
293293

294294
func ExampleUsersAPI() {
295-
// Create influxdb client
295+
// Create a new client using an InfluxDB server base URL and an authentication token
296296
client := influxdb2.NewClient("http://localhost:9999", "my-token")
297297

298298
// Find organization
@@ -326,7 +326,7 @@ func ExampleUsersAPI() {
326326
}
327327

328328
func ExampleLabelsAPI() {
329-
// Create influxdb client
329+
// Create a new client using an InfluxDB server base URL and an authentication token
330330
client := influxdb2.NewClient("http://localhost:9999", "my-token")
331331

332332
ctx := context.Background()
@@ -360,7 +360,7 @@ func ExampleLabelsAPI() {
360360
}
361361

362362
func ExampleDeleteAPI() {
363-
// Create influxdb client
363+
// Create a new client using an InfluxDB server base URL and an authentication token
364364
client := influxdb2.NewClient("http://localhost:9999", "my-token")
365365

366366
ctx := context.Background()

client.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,18 @@ type clientImpl struct {
7979
}
8080

8181
// NewClient creates Client for connecting to given serverURL with provided authentication token, with the default options.
82-
// Authentication token can be empty in case of connecting to newly installed InfluxDB server, which has not been set up yet.
83-
// In such case Setup will set authentication token
82+
// serverURL is the InfluxDB server base URL, e.g. http://localhost:9999,
83+
// authToken is an authentication token. It can be empty in case of connecting to newly installed InfluxDB server, which has not been set up yet.
84+
// In such case, calling Setup() will set the authentication token.
8485
func NewClient(serverURL string, authToken string) Client {
8586
return NewClientWithOptions(serverURL, authToken, DefaultOptions())
8687
}
8788

8889
// NewClientWithOptions creates Client for connecting to given serverURL with provided authentication token
89-
// and configured with custom Options
90-
// Authentication token can be empty in case of connecting to newly installed InfluxDB server, which has not been set up yet.
91-
// In such case Setup will set authentication token
90+
// and configured with custom Options.
91+
// serverURL is the InfluxDB server base URL, e.g. http://localhost:9999,
92+
// authToken is an authentication token. It can be empty in case of connecting to newly installed InfluxDB server, which has not been set up yet.
93+
// In such case, calling Setup() will set authentication token
9294
func NewClientWithOptions(serverURL string, authToken string, options *Options) Client {
9395
normServerURL := serverURL
9496
if !strings.HasSuffix(normServerURL, "/") {

examples_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import (
99
)
1010

1111
func ExampleClient_newClient() {
12-
// Create client
12+
// Create a new client using an InfluxDB server base URL and an authentication token
1313
client := influxdb2.NewClient("http://localhost:9999", "my-token")
1414

1515
// always close client at the end
1616
defer client.Close()
1717
}
1818

1919
func ExampleClient_newClientWithOptions() {
20+
// Create a new client using an InfluxDB server base URL and an authentication token
2021
// Create client and set batch size to 20
2122
client := influxdb2.NewClientWithOptions("http://localhost:9999", "my-token",
2223
influxdb2.DefaultOptions().SetBatchSize(20))

0 commit comments

Comments
 (0)