Commit Graph

19 Commits

Author SHA1 Message Date
Bartlomiej Plotka 2280fb19f6
Revert "change api http.client to interface" 2023-12-22 11:16:00 +00:00
Roy Reshef 24d59e9b9b change client to interface, allow override by other implementations (e.g. github.com/hashicorp/go-retryablehttp)
Signed-off-by: Roy Reshef <rreshef@densify.com>
2023-11-22 16:52:47 -05:00
Christoph Mewes 618194de6a
fix assorted oddities found by golangci-lint (#1040)
* fix assorted oddities found by golangci-lint

Signed-off-by: Christoph Mewes <christoph@kubermatic.com>

* permanently enable the linters

Signed-off-by: Christoph Mewes <christoph@kubermatic.com>

* post-rebase blues

Signed-off-by: Christoph Mewes <christoph@kubermatic.com>
2022-08-03 06:30:51 +02:00
S Santhosh Nagaraj 404809144b
client: Allow configuration of http client (#1025)
* client: Allow configuration of http client

Signed-off-by: yolossn <nssvlr@gmail.com>

* Add api.Config validation to prevent confusion

Update config documentation

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

Co-authored-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-04-29 15:02:44 +01:00
Bryan Boreham 4dd3cbb4ab
API client: make http reads more efficient (#976)
Replace `io.ReadAll` with `bytes.Buffer.ReadFrom`.
Both need to resize a buffer until they have finished reading;
the former increases by 1.25x each time while the latter uses 2x.

Also added a benchmark to demonstrate the benefit:
name             old time/op    new time/op    delta
Client/4KB-8       35.9µs ± 4%    35.3µs ± 3%     ~     (p=0.310 n=5+5)
Client/50KB-8      83.1µs ± 8%    69.5µs ± 1%  -16.37%  (p=0.008 n=5+5)
Client/1000KB-8     891µs ± 6%     750µs ± 0%  -15.83%  (p=0.016 n=5+4)
Client/2000KB-8    1.74ms ± 2%    1.35ms ± 1%  -22.72%  (p=0.008 n=5+5)

name             old alloc/op   new alloc/op   delta
Client/4KB-8       20.2kB ± 0%    20.4kB ± 0%   +1.26%  (p=0.008 n=5+5)
Client/50KB-8       218kB ± 0%     136kB ± 0%  -37.65%  (p=0.008 n=5+5)
Client/1000KB-8    5.88MB ± 0%    2.11MB ± 0%  -64.10%  (p=0.008 n=5+5)
Client/2000KB-8    11.7MB ± 0%     4.2MB ± 0%  -63.93%  (p=0.008 n=5+5)

name             old allocs/op  new allocs/op  delta
Client/4KB-8         75.0 ± 0%      72.0 ± 0%   -4.00%  (p=0.008 n=5+5)
Client/50KB-8         109 ± 0%        98 ± 0%  -10.09%  (p=0.079 n=4+5)
Client/1000KB-8       617 ± 0%       593 ± 0%   -3.89%  (p=0.008 n=5+5)
Client/2000KB-8     1.13k ± 0%     1.09k ± 0%   -3.27%  (p=0.008 n=5+5)

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2022-01-25 11:16:10 +01:00
Joe Elliott 88792b1169 Moved warnings into apiclient
Signed-off-by: Joe Elliott <number101010@gmail.com>
2019-12-11 10:04:00 -05:00
Joe Elliott 7f4279992e First pass unravel
Signed-off-by: Joe Elliott <number101010@gmail.com>
2019-12-10 15:16:44 -05:00
Thomas Jackson 1335ef46bd Pass warnings through on non-error responses (#599)
Return warnings as a separate string slice to simplify handling.

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-06-14 01:40:59 +02:00
Thomas Jackson d5f3c8d55d Add storage.Warnings to client
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>

Fixes #560
2019-05-21 07:36:05 -07:00
Thomas Jackson a4daf0098c Implement POST with get fallback for Query/QueryRange (#557)
* Implement POST with get fallback for Query/QueryRange

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-04-30 10:13:48 +03:00
Bjoern Rabenstein 1173d73405 Increase minimum required Go version to 1.9
This allows us to simplify a bunch of code while still supporting the
last four Go minor versions.

We have also run into minor annoyances a couple of times by now to
keep supporting 1.7 and 1.8.

It's time to pull the plug!

Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
2019-04-28 23:28:57 +02:00
Louis DeLosSantos 12af604cf2 wait for done before writing to shared resp body (#532)
Signed-off-by: Louis Delossantos <ldelossa.ld@gmail.com>
2019-01-28 11:53:16 +03:00
alileza bc3c7b9dd1 Update DefaultRoundTripper to DialContext because Dial is deprecated
Signed-off-by: alileza <alirezayahya@gmail.com>
2018-06-27 12:02:52 +02:00
André Carvalho 8077e4bd69
api: fix typo in comments 2017-04-25 18:17:16 -03:00
André Carvalho 5d19d9de34
api: renames create client func 2017-04-25 11:37:13 -03:00
André Carvalho 6fdb468212
api: add build tag for go 1.7 2017-04-24 18:05:17 -03:00
André Carvalho 09dcce7042
api: uses context from net/http
This commit removes the now unnecessary CancelableTransport and rely on
the net/http context support.
2017-04-20 10:31:18 -03:00
André Carvalho 11fae2ef0c
api: uses stdlib context 2017-04-20 09:57:46 -03:00
André Carvalho 349922b38c
api: creates versioned package for prometheus v1 api
This commit creates a new package to hold the prometheus
v1 API interface. This interface will contain all the funcionality
exposed by Prometheus v1 HTTP API.

The underlying http client is kept on the api package since it
may be reused across diferent API versions and also by the Alertmanager
api package (to come.)
2017-04-19 18:24:14 -03:00