influxdata / influxdata/influxdb1-client

NewClient should accept pointer to a http.Client

Open
#4 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
192
Forks
109
PR merge metrics
No merged PRs in 30d

Description

While working with the client, we noticed that NewClient creates an `http.Client` with a custom transport.

https://github.com/influxdata/influxdb1-client/blob/f8cdb5d5f1752d3578a055342232883f45b7283d/influxdb.go#L164

There is no option to pass settings like `MaxIdleConns` to the transport which means the client ends up using unlimited connections. I propose that the NewClient should be taking in a `*http.Client` similar to [how the GitHub client](https://godoc.org/github.com/google/go-github/github#NewClient) does.

https://0x46.net/thoughts/2018/12/29/go-libraries/ also talks about some issues with hardcoding an `http.Client`. I am happy to send a PR for the change if the proposal sounds good.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at influxdb.go around line 164 and inspect how NewClient creates and configures the http.Client and its transport. Check the existing constructor usage, then define done as allowing callers to provide a *http.Client whose transport settings, including connection limits, are honored.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.