Skip to content

Commit

Permalink
Merge pull request #254 from bonitoo-io/docs/api_doc_imp
Browse files Browse the repository at this point in the history
fix: fixed golint check issues
  • Loading branch information
vlastahajek committed Apr 30, 2021
2 parents 36181ee + 00188e4 commit daf6fa4
Show file tree
Hide file tree
Showing 25 changed files with 233 additions and 142 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Expand Up @@ -41,6 +41,7 @@ jobs:
- run: go get -v -t -d ./...
- run: go vet ./...
- run: go get honnef.co/go/tools/cmd/staticcheck && staticcheck --checks='all' --tags e2e ./...
- run: go get golang.org/x/lint/golint && golint ./...
- run:
name: "Start InfluxDB service"
command: ./scripts/influxdb-restart.sh
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,7 @@
### Bug fixes
1. [#252](https://github.com/influxdata/influxdb-client-go/pull/252) Fixed panic when getting not present standard Flux columns
1. [#253](https://github.com/influxdata/influxdb-client-go/pull/253) Conditional debug logging of buffers
1. [#254](https://github.com/influxdata/influxdb-client-go/pull/254) Fixed golint issues

## 2.2.3 [2021-04-01]
### Bug fixes
Expand Down
31 changes: 15 additions & 16 deletions README.md
Expand Up @@ -387,26 +387,25 @@ most importantly reusing HTTP connections.
For efficient reuse of HTTP resources among multiple clients, create an HTTP client and use `Options.SetHTTPClient()` for setting it to all clients:
```go
// Create HTTP client
httpClient := &http.Client{
Timeout: time.Second * time.Duration(60),
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
}).DialContext,
TLSHandshakeTimeout: 5 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 90 * time.Second,
},
}
httpClient := &http.Client{
Timeout: time.Second * time.Duration(60),
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
}).DialContext,
TLSHandshakeTimeout: 5 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 90 * time.Second,
},
}
// Client for server 1
client1 := influxdb2.NewClientWithOptions("https://server:8086", "my-token", influxdb2.DefaultOptions().SetHTTPClient(httpClient))
// Client for server 2
client2 := influxdb2.NewClientWithOptions("https://server:9999", "my-token2", influxdb2.DefaultOptions().SetHTTPClient(httpClient))

```

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,
Expand Down
12 changes: 7 additions & 5 deletions api/authorizations.go
Expand Up @@ -36,10 +36,12 @@ type AuthorizationsAPI interface {
DeleteAuthorizationWithID(ctx context.Context, authID string) error
}

// authorizationsAPI implements AuthorizationsAPI
type authorizationsAPI struct {
apiClient *domain.ClientWithResponses
}

// NewAuthorizationsAPI creates new instance of AuthorizationsAPI
func NewAuthorizationsAPI(apiClient *domain.ClientWithResponses) AuthorizationsAPI {
return &authorizationsAPI{
apiClient: apiClient,
Expand Down Expand Up @@ -77,7 +79,7 @@ func (a *authorizationsAPI) listAuthorizations(ctx context.Context, query *domai
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200.Authorizations, nil
}
Expand All @@ -89,10 +91,10 @@ func (a *authorizationsAPI) CreateAuthorization(ctx context.Context, authorizati
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
if response.JSON400 != nil {
return nil, domain.DomainErrorToError(response.JSON400, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSON400, response.StatusCode())
}
return response.JSON201, nil
}
Expand All @@ -115,7 +117,7 @@ func (a *authorizationsAPI) UpdateAuthorizationStatusWithID(ctx context.Context,
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200, nil
}
Expand All @@ -135,7 +137,7 @@ func (a *authorizationsAPI) DeleteAuthorizationWithID(ctx context.Context, authI
return err
}
if response.JSONDefault != nil {
return domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return nil
}
33 changes: 17 additions & 16 deletions api/buckets.go
Expand Up @@ -62,10 +62,12 @@ type BucketsAPI interface {
RemoveOwnerWithID(ctx context.Context, bucketID, memberID string) error
}

// bucketsAPI implements BucketsAPI
type bucketsAPI struct {
apiClient *domain.ClientWithResponses
}

// NewBucketsAPI creates new instance of BucketsAPI
func NewBucketsAPI(apiClient *domain.ClientWithResponses) BucketsAPI {
return &bucketsAPI{
apiClient: apiClient,
Expand Down Expand Up @@ -94,7 +96,7 @@ func (b *bucketsAPI) getBuckets(ctx context.Context, params *domain.GetBucketsPa
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200.Buckets, nil
}
Expand All @@ -106,13 +108,12 @@ func (b *bucketsAPI) FindBucketByName(ctx context.Context, bucketName string) (*
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
if response.JSON200.Buckets != nil && len(*response.JSON200.Buckets) > 0 {
return &(*response.JSON200.Buckets)[0], nil
} else {
return nil, fmt.Errorf("bucket '%s' not found", bucketName)
}
return nil, fmt.Errorf("bucket '%s' not found", bucketName)
}

func (b *bucketsAPI) FindBucketByID(ctx context.Context, bucketID string) (*domain.Bucket, error) {
Expand All @@ -122,7 +123,7 @@ func (b *bucketsAPI) FindBucketByID(ctx context.Context, bucketID string) (*doma
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200, nil
}
Expand All @@ -144,10 +145,10 @@ func (b *bucketsAPI) createBucket(ctx context.Context, bucketReq *domain.PostBuc
return nil, err
}
if response.JSON422 != nil {
return nil, domain.DomainErrorToError(response.JSON422, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSON422, response.StatusCode())
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON201, nil
}
Expand Down Expand Up @@ -182,10 +183,10 @@ func (b *bucketsAPI) DeleteBucketWithID(ctx context.Context, bucketID string) er
return err
}
if response.JSONDefault != nil {
return domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
if response.JSON404 != nil {
return domain.DomainErrorToError(response.JSON404, response.StatusCode())
return domain.ErrorToHTTPError(response.JSON404, response.StatusCode())
}
return nil
}
Expand All @@ -197,7 +198,7 @@ func (b *bucketsAPI) UpdateBucket(ctx context.Context, bucket *domain.Bucket) (*
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200, nil
}
Expand All @@ -213,7 +214,7 @@ func (b *bucketsAPI) GetMembersWithID(ctx context.Context, bucketID string) (*[]
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200.Users, nil
}
Expand All @@ -230,7 +231,7 @@ func (b *bucketsAPI) AddMemberWithID(ctx context.Context, bucketID, memberID str
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON201, nil
}
Expand All @@ -246,7 +247,7 @@ func (b *bucketsAPI) RemoveMemberWithID(ctx context.Context, bucketID, memberID
return err
}
if response.JSONDefault != nil {
return domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return nil
}
Expand All @@ -262,7 +263,7 @@ func (b *bucketsAPI) GetOwnersWithID(ctx context.Context, bucketID string) (*[]d
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200.Users, nil
}
Expand All @@ -279,7 +280,7 @@ func (b *bucketsAPI) AddOwnerWithID(ctx context.Context, bucketID, memberID stri
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON201, nil
}
Expand All @@ -295,7 +296,7 @@ func (b *bucketsAPI) RemoveOwnerWithID(ctx context.Context, bucketID, memberID s
return err
}
if response.JSONDefault != nil {
return domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return nil
}
10 changes: 6 additions & 4 deletions api/delete.go
Expand Up @@ -24,10 +24,12 @@ type DeleteAPI interface {
DeleteWithName(ctx context.Context, orgName, bucketName string, start, stop time.Time, predicate string) error
}

// deleteAPI implements DeleteAPI
type deleteAPI struct {
apiClient *domain.ClientWithResponses
}

// NewDeleteAPI creates new instance of DeleteAPI
func NewDeleteAPI(apiClient *domain.ClientWithResponses) DeleteAPI {
return &deleteAPI{
apiClient: apiClient,
Expand All @@ -40,16 +42,16 @@ func (d *deleteAPI) delete(ctx context.Context, params *domain.PostDeleteParams,
return err
}
if resp.JSON404 != nil {
return domain.DomainErrorToError(resp.JSON404, resp.StatusCode())
return domain.ErrorToHTTPError(resp.JSON404, resp.StatusCode())
}
if resp.JSON403 != nil {
return domain.DomainErrorToError(resp.JSON403, resp.StatusCode())
return domain.ErrorToHTTPError(resp.JSON403, resp.StatusCode())
}
if resp.JSON400 != nil {
return domain.DomainErrorToError(resp.JSON400, resp.StatusCode())
return domain.ErrorToHTTPError(resp.JSON400, resp.StatusCode())
}
if resp.JSONDefault != nil {
return domain.DomainErrorToError(resp.JSONDefault, resp.StatusCode())
return domain.ErrorToHTTPError(resp.JSONDefault, resp.StatusCode())
}
return nil
}
Expand Down
16 changes: 9 additions & 7 deletions api/labels.go
Expand Up @@ -40,10 +40,12 @@ type LabelsAPI interface {
DeleteLabel(ctx context.Context, label *domain.Label) error
}

// labelsAPI implements LabelsAPI
type labelsAPI struct {
apiClient *domain.ClientWithResponses
}

// NewLabelsAPI creates new instance of LabelsAPI
func NewLabelsAPI(apiClient *domain.ClientWithResponses) LabelsAPI {
return &labelsAPI{
apiClient: apiClient,
Expand All @@ -61,7 +63,7 @@ func (u *labelsAPI) getLabels(ctx context.Context, params *domain.GetLabelsParam
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return (*[]domain.Label)(response.JSON200.Labels), nil
}
Expand All @@ -82,7 +84,7 @@ func (u *labelsAPI) FindLabelByID(ctx context.Context, labelID string) (*domain.
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200.Label, nil
}
Expand Down Expand Up @@ -121,7 +123,7 @@ func (u *labelsAPI) CreateLabel(ctx context.Context, label *domain.LabelCreateRe
return nil, err
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON201.Label, nil
}
Expand All @@ -141,10 +143,10 @@ func (u *labelsAPI) UpdateLabel(ctx context.Context, label *domain.Label) (*doma
return nil, err
}
if response.JSON404 != nil {
return nil, domain.DomainErrorToError(response.JSON404, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSON404, response.StatusCode())
}
if response.JSONDefault != nil {
return nil, domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return nil, domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return response.JSON200.Label, nil
}
Expand All @@ -160,10 +162,10 @@ func (u *labelsAPI) DeleteLabelWithID(ctx context.Context, labelID string) error
return err
}
if response.JSON404 != nil {
return domain.DomainErrorToError(response.JSON404, response.StatusCode())
return domain.ErrorToHTTPError(response.JSON404, response.StatusCode())
}
if response.JSONDefault != nil {
return domain.DomainErrorToError(response.JSONDefault, response.StatusCode())
return domain.ErrorToHTTPError(response.JSONDefault, response.StatusCode())
}
return nil
}

0 comments on commit daf6fa4

Please sign in to comment.