Skip to content

Commit

Permalink
Merge pull request #196 from bonitoo-io/feat/change_port
Browse files Browse the repository at this point in the history
feat: Changing server port 9999 -> 8086
  • Loading branch information
vlastahajek authored Sep 30, 2020
2 parents 466f450 + a810ba6 commit f33d198
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
environment:
ENV: CI
GO111MODULE: "on"
INFLUXDB2_URL: "http://localhost:9999"
INFLUXDB_URL: "http://localhost:8086"
INFLUXDB2_ONBOARDING_URL: "http://localhost:9990"
INFLUXDB2_URL: "http://localhost:8086"
INFLUXDB_URL: "http://localhost:8087"
INFLUXDB2_ONBOARDING_URL: "http://localhost:8089"
steps:
- checkout
# - run:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## 2.1.0 [in progress]
### Features
1. [#193](https://github.com/influxdata/influxdb-client-go/pull/193) Added authentication using username and password. See `UsersAPI.SignIn()` and `UsersAPI.SignOut()`
1. [#204](https://github.com/influxdata/influxdb-client-go/pull/204) Synced with InfluxDB 2 RC0 swagger. Added pagination to Organizations API and `After` paging param to Buckets API.

### Bug fixes
1. [#191](https://github.com/influxdata/influxdb-client-go/pull/191) Fixed QueryTableResult.Next() failed to parse boolean datatype.
1. [#192](https://github.com/influxdata/influxdb-client-go/pull/192) Client.Close() closes idle connections of internally created HTTP client

### Documentation
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.
1. [#196](https://github.com/influxdata/influxdb-client-go/pull/196) Changed default server port 9999 to 8086 in docs and examples

## 2.0.1 [2020-08-14]
### Bug fixes
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import (

func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Use blocking write client for writes to desired bucket
writeAPI := client.WriteAPIBlocking("my-org", "my-bucket")
// Create point using full params constructor
Expand Down Expand Up @@ -120,14 +120,14 @@ func main() {
The InfluxDBClient uses set of options to configure behavior. These are available in the [Options](https://github.com/influxdata/influxdb-client-go/blob/master/options.go) object
Creating a client instance using
```go
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
```
will use the default options.

To set different configuration values, e.g. to set gzip compression and trust all server certificates, get default options
and change what is needed:
```go
client := influxdb2.NewClientWithOptions("http://localhost:9999", "my-token",
client := influxdb2.NewClientWithOptions("http://localhost:8086", "my-token",
influxdb2.DefaultOptions().
SetUseGZip(true).
SetTLSConfig(&tls.Config{
Expand Down Expand Up @@ -163,7 +163,7 @@ import (
func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
// and set batch size to 20
client := influxdb2.NewClientWithOptions("http://localhost:9999", "my-token",
client := influxdb2.NewClientWithOptions("http://localhost:8086", "my-token",
influxdb2.DefaultOptions().SetBatchSize(20))
// Get non-blocking write client
writeAPI := client.WriteAPI("my-org","my-bucket")
Expand Down Expand Up @@ -212,7 +212,7 @@ import (

func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get non-blocking write client
writeAPI := client.WriteAPI("my-org", "my-bucket")
// Get errors channel
Expand Down Expand Up @@ -263,7 +263,7 @@ import (

func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get blocking write client
writeAPI := client.WriteAPIBlocking("my-org","my-bucket")
// write some points
Expand Down Expand Up @@ -314,7 +314,7 @@ import (

func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get query client
queryAPI := client.QueryAPI("my-org")
// get QueryTableResult
Expand Down Expand Up @@ -357,7 +357,7 @@ import (

func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get query client
queryAPI := client.QueryAPI("my-org")
// Query and get complete result as a string
Expand Down
2 changes: 1 addition & 1 deletion api/authorizations_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func getEnvValue(key, defVal string) string {

func init() {
authToken = getEnvValue("INFLUXDB2_TOKEN", "my-token")
serverURL = getEnvValue("INFLUXDB2_URL", "http://localhost:9999")
serverURL = getEnvValue("INFLUXDB2_URL", "http://localhost:8086")
}

func TestAuthorizationsAPI(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions api/buckets_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestBucketsAPI_paging(t *testing.T) {
// collect all buckets including system ones created for new organization
buckets, err := bucketsAPI.GetBuckets(ctx)
require.Nil(t, err, err)
//store #all buckets before creating new ones
//store #all buckets before creating new ones (typically 5 - 2xsytem buckets (_tasks, _monitoring) + initial bucket "my-bucket")
bucketsNum := len(*buckets)

// create new buckets inside org
Expand All @@ -219,7 +219,8 @@ func TestBucketsAPI_paging(t *testing.T) {
buckets, err = bucketsAPI.GetBuckets(ctx, api.PagingWithOffset(20))
require.Nil(t, err, err)
require.NotNil(t, buckets)
assert.Len(t, *buckets, 10+bucketsNum)
// should return 15, but sometimes repeats system buckets also in 2nd page
assert.True(t, len(*buckets) >= 10+bucketsNum, "Invalid len: %d >= %d", len(*buckets), 10+bucketsNum)
// test paging with increase limit to cover all buckets
buckets, err = bucketsAPI.GetBuckets(ctx, api.PagingWithLimit(100))
require.Nil(t, err, err)
Expand Down
24 changes: 12 additions & 12 deletions api/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

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

ctx := context.Background()
// Get Buckets API client
Expand Down Expand Up @@ -45,7 +45,7 @@ func ExampleBucketsAPI() {

func ExampleWriteAPIBlocking() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get blocking write client
writeAPI := client.WriteAPIBlocking("my-org", "my-bucket")
// write some points
Expand Down Expand Up @@ -78,7 +78,7 @@ func ExampleWriteAPIBlocking() {

func ExampleWriteAPI() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get non-blocking write client
writeAPI := client.WriteAPI("my-org", "my-bucket")
// write some points
Expand Down Expand Up @@ -110,7 +110,7 @@ func ExampleWriteAPI() {

func ExampleWriteAPI_errors() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get non-blocking write client
writeAPI := client.WriteAPI("my-org", "my-bucket")
// Get errors channel
Expand Down Expand Up @@ -145,7 +145,7 @@ func ExampleWriteAPI_errors() {

func ExampleQueryAPI_query() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get query client
queryAPI := client.QueryAPI("my-org")
// get QueryTableResult
Expand Down Expand Up @@ -173,7 +173,7 @@ func ExampleQueryAPI_query() {

func ExampleQueryAPI_queryRaw() {
// Create a new client using an InfluxDB server base URL and an authentication token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Get query client
queryAPI := client.QueryAPI("my-org")
// Query and get complete result as a string
Expand All @@ -191,7 +191,7 @@ func ExampleQueryAPI_queryRaw() {

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

// Get Organizations API client
orgAPI := client.OrganizationsAPI()
Expand Down Expand Up @@ -239,7 +239,7 @@ func ExampleOrganizationsAPI() {

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

// Find user to grant permission
user, err := client.UsersAPI().FindUserByName(context.Background(), "user-01")
Expand Down Expand Up @@ -293,7 +293,7 @@ func ExampleAuthorizationsAPI() {

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

// Find organization
org, err := client.OrganizationsAPI().FindOrganizationByName(context.Background(), "my-org")
Expand Down Expand Up @@ -327,7 +327,7 @@ func ExampleUsersAPI() {

func ExampleUsersAPI_signInOut() {
// Create a new client using an InfluxDB server base URL and empty token
client := influxdb2.NewClient("http://localhost:9999", "")
client := influxdb2.NewClient("http://localhost:8086", "")
// Always close client at the end
defer client.Close()

Expand All @@ -354,7 +354,7 @@ func ExampleUsersAPI_signInOut() {

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

ctx := context.Background()
// Get Labels API client
Expand Down Expand Up @@ -388,7 +388,7 @@ func ExampleLabelsAPI() {

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

ctx := context.Background()
// Get Delete API client
Expand Down
2 changes: 1 addition & 1 deletion api/http/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//
// Service can be obtained from client using HTTPService() method.
// It can be also created directly. To instantiate a Service use NewService(). Remember, the authorization param is in form "Token your-auth-token". e.g. "Token DXnd7annkGteV5Wqx9G3YjO9Ezkw87nHk8OabcyHCxF5451kdBV0Ag2cG7OmZZgCUTHroagUPdxbuoyen6TSPw==".
// srv := http.NewService("http://localhost:9999", "Token my-token", http.DefaultOptions())
// srv := http.NewService("http://localhost:8086", "Token my-token", http.DefaultOptions())
package http

import (
Expand Down
6 changes: 3 additions & 3 deletions api/http/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

func TestService(t *testing.T) {
srv := NewService("http://localhost:9999/aa/", "Token my-token", DefaultOptions())
assert.Equal(t, "http://localhost:9999/aa/", srv.ServerURL())
assert.Equal(t, "http://localhost:9999/aa/api/v2/", srv.ServerAPIURL())
srv := NewService("http://localhost:8086/aa/", "Token my-token", DefaultOptions())
assert.Equal(t, "http://localhost:8086/aa/", srv.ServerURL())
assert.Equal(t, "http://localhost:8086/aa/api/v2/", srv.ServerAPIURL())
assert.Equal(t, "Token my-token", srv.Authorization())
}
4 changes: 2 additions & 2 deletions api/users_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestUsersAPI_requestFailing(t *testing.T) {

func TestSignInOut(t *testing.T) {
ctx := context.Background()
client := influxdb2.NewClient("http://localhost:9999", "")
client := influxdb2.NewClient("http://localhost:8086", "")

usersAPI := client.UsersAPI()

Expand Down Expand Up @@ -198,7 +198,7 @@ func TestSignInOut(t *testing.T) {
require.NotNil(t, user)

// 2nd client to use for new user auth
client2 := influxdb2.NewClient("http://localhost:9999", "")
client2 := influxdb2.NewClient("http://localhost:8086", "")

err = usersAPI.UpdateUserPassword(ctx, user, "123password")
assert.Nil(t, err)
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type clientImpl struct {
}

// NewClient creates Client for connecting to given serverURL with provided authentication token, with the default options.
// serverURL is the InfluxDB server base URL, e.g. http://localhost:9999,
// serverURL is the InfluxDB server base URL, e.g. http://localhost:8086,
// 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.
// In such case, calling Setup() will set the authentication token.
func NewClient(serverURL string, authToken string) Client {
Expand All @@ -89,7 +89,7 @@ func NewClient(serverURL string, authToken string) Client {

// NewClientWithOptions creates Client for connecting to given serverURL with provided authentication token
// and configured with custom Options.
// serverURL is the InfluxDB server base URL, e.g. http://localhost:9999,
// serverURL is the InfluxDB server base URL, e.g. http://localhost:8086,
// 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.
// In such case, calling Setup() will set authentication token
func NewClientWithOptions(serverURL string, authToken string, options *Options) Client {
Expand Down
8 changes: 4 additions & 4 deletions client_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func getEnvValue(key, defVal string) string {

func init() {
authToken = getEnvValue("INFLUXDB2_TOKEN", "my-token")
serverURL = getEnvValue("INFLUXDB2_URL", "http://localhost:9999")
serverV1URL = getEnvValue("INFLUXDB_URL", "http://localhost:8086")
onboardingURL = getEnvValue("INFLUXDB2_ONBOARDING_URL", "http://localhost:9990")
serverURL = getEnvValue("INFLUXDB2_URL", "http://localhost:8086")
serverV1URL = getEnvValue("INFLUXDB_URL", "http://localhost:8087")
onboardingURL = getEnvValue("INFLUXDB2_ONBOARDING_URL", "http://localhost:8089")
}

func TestSetup(t *testing.T) {
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestQueryV1Compatibility(t *testing.T) {
}

func TestHTTPService(t *testing.T) {
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
apiClient := domain.NewClientWithResponses(client.HTTPService())
org, err := client.OrganizationsAPI().FindOrganizationByName(context.Background(), "my-org")
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func TestUrls(t *testing.T) {
serverAPIURL string
writeURLPrefix string
}{
{"http://host:9999", "http://host:9999/api/v2/", "http://host:9999/api/v2/write"},
{"http://host:9999/", "http://host:9999/api/v2/", "http://host:9999/api/v2/write"},
{"http://host:9999/path", "http://host:9999/path/api/v2/", "http://host:9999/path/api/v2/write"},
{"http://host:9999/path/", "http://host:9999/path/api/v2/", "http://host:9999/path/api/v2/write"},
{"http://host:9999/path1/path2/path3", "http://host:9999/path1/path2/path3/api/v2/", "http://host:9999/path1/path2/path3/api/v2/write"},
{"http://host:9999/path1/path2/path3/", "http://host:9999/path1/path2/path3/api/v2/", "http://host:9999/path1/path2/path3/api/v2/write"},
{"http://host:8086", "http://host:8086/api/v2/", "http://host:8086/api/v2/write"},
{"http://host:8086/", "http://host:8086/api/v2/", "http://host:8086/api/v2/write"},
{"http://host:8086/path", "http://host:8086/path/api/v2/", "http://host:8086/path/api/v2/write"},
{"http://host:8086/path/", "http://host:8086/path/api/v2/", "http://host:8086/path/api/v2/write"},
{"http://host:8086/path1/path2/path3", "http://host:8086/path1/path2/path3/api/v2/", "http://host:8086/path1/path2/path3/api/v2/write"},
{"http://host:8086/path1/path2/path3/", "http://host:8086/path1/path2/path3/api/v2/", "http://host:8086/path1/path2/path3/api/v2/write"},
}
for _, url := range urls {
t.Run(url.serverURL, func(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

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

// Always close client at the end
defer client.Close()
Expand All @@ -19,7 +19,7 @@ func ExampleClient_newClient() {
func ExampleClient_newClientWithOptions() {
// Create a new client using an InfluxDB server base URL and an authentication token
// Create client and set batch size to 20
client := influxdb2.NewClientWithOptions("http://localhost:9999", "my-token",
client := influxdb2.NewClientWithOptions("http://localhost:8086", "my-token",
influxdb2.DefaultOptions().SetBatchSize(20))

// Always close client at the end
Expand All @@ -28,7 +28,7 @@ func ExampleClient_newClientWithOptions() {

func ExampleClient_customServerAPICall() {
// Create a new client using an InfluxDB server base URL and empty token
client := influxdb2.NewClient("http://localhost:9999", "my-token")
client := influxdb2.NewClient("http://localhost:8086", "my-token")
// Always close client at the end
defer client.Close()
// Get generated client for server API calls
Expand Down
8 changes: 4 additions & 4 deletions internal/write/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAddDefaultTags(t *testing.T) {

func TestDefaultRetryDelay(t *testing.T) {
log.Log.SetLogLevel(log.DebugLevel)
hs := test.NewTestService(t, "http://localhost:9999")
hs := test.NewTestService(t, "http://localhost:8086")
opts := write.DefaultOptions()
ctx := context.Background()
srv := NewService("my-org", "my-bucket", hs, opts)
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestDefaultRetryDelay(t *testing.T) {

func TestCustomRetryDelayWithFLush(t *testing.T) {
log.Log.SetLogLevel(log.DebugLevel)
hs := test.NewTestService(t, "http://localhost:9999")
hs := test.NewTestService(t, "http://localhost:8086")
opts := write.DefaultOptions().SetRetryInterval(1)
ctx := context.Background()
srv := NewService("my-org", "my-bucket", hs, opts)
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestCustomRetryDelayWithFLush(t *testing.T) {

func TestBufferOverwrite(t *testing.T) {
log.Log.SetLogLevel(log.DebugLevel)
hs := test.NewTestService(t, "http://localhost:9999")
hs := test.NewTestService(t, "http://localhost:8086")
//
opts := write.DefaultOptions().SetRetryInterval(1).SetRetryBufferLimit(15000)
ctx := context.Background()
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestBufferOverwrite(t *testing.T) {

func TestMaxRetryInterval(t *testing.T) {
log.Log.SetLogLevel(log.DebugLevel)
hs := test.NewTestService(t, "http://localhost:9999")
hs := test.NewTestService(t, "http://localhost:8086")
//
opts := write.DefaultOptions().SetRetryInterval(1).SetMaxRetryInterval(10)
ctx := context.Background()
Expand Down
Loading

0 comments on commit f33d198

Please sign in to comment.