mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
remote: Expose ClientConfig type (see #3165)
This commit is contained in:
parent
16f71a7723
commit
3760f56c0c
|
@ -45,26 +45,27 @@ type Client struct {
|
||||||
readRecent bool
|
readRecent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientConfig struct {
|
// ClientConfig configures a Client.
|
||||||
url *config.URL
|
type ClientConfig struct {
|
||||||
timeout model.Duration
|
URL *config.URL
|
||||||
readRecent bool
|
Timeout model.Duration
|
||||||
httpClientConfig config.HTTPClientConfig
|
ReadRecent bool
|
||||||
|
HTTPClientConfig config.HTTPClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a new Client.
|
// NewClient creates a new Client.
|
||||||
func NewClient(index int, conf *clientConfig) (*Client, error) {
|
func NewClient(index int, conf *ClientConfig) (*Client, error) {
|
||||||
httpClient, err := httputil.NewClientFromConfig(conf.httpClientConfig, "remote_storage")
|
httpClient, err := httputil.NewClientFromConfig(conf.HTTPClientConfig, "remote_storage")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
index: index,
|
index: index,
|
||||||
url: conf.url,
|
url: conf.URL,
|
||||||
client: httpClient,
|
client: httpClient,
|
||||||
timeout: time.Duration(conf.timeout),
|
timeout: time.Duration(conf.Timeout),
|
||||||
readRecent: conf.readRecent,
|
readRecent: conf.ReadRecent,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +130,8 @@ func (c *Client) Read(ctx context.Context, from, through int64, matchers []*labe
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &prompb.ReadRequest{
|
req := &prompb.ReadRequest{
|
||||||
|
// TODO: Support batching multiple queries into one read request,
|
||||||
|
// as the protobuf interface allows for it.
|
||||||
Queries: []*prompb.Query{
|
Queries: []*prompb.Query{
|
||||||
query,
|
query,
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,9 +64,9 @@ func TestStoreHTTPErrorHandling(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := NewClient(0, &clientConfig{
|
c, err := NewClient(0, &ClientConfig{
|
||||||
url: &config.URL{serverURL},
|
URL: &config.URL{serverURL},
|
||||||
timeout: model.Duration(time.Second),
|
Timeout: model.Duration(time.Second),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
@ -184,11 +184,11 @@ func TestRemoteStorageQuerier(t *testing.T) {
|
||||||
s := NewStorage(nil, func() (int64, error) { return test.localStartTime, nil })
|
s := NewStorage(nil, func() (int64, error) { return test.localStartTime, nil })
|
||||||
s.clients = []*Client{}
|
s.clients = []*Client{}
|
||||||
for _, readRecent := range test.readRecentClients {
|
for _, readRecent := range test.readRecentClients {
|
||||||
c, _ := NewClient(0, &clientConfig{
|
c, _ := NewClient(0, &ClientConfig{
|
||||||
url: nil,
|
URL: nil,
|
||||||
timeout: model.Duration(30 * time.Second),
|
Timeout: model.Duration(30 * time.Second),
|
||||||
httpClientConfig: config.HTTPClientConfig{},
|
HTTPClientConfig: config.HTTPClientConfig{},
|
||||||
readRecent: readRecent,
|
ReadRecent: readRecent,
|
||||||
})
|
})
|
||||||
s.clients = append(s.clients, c)
|
s.clients = append(s.clients, c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,10 +58,10 @@ func (s *Storage) ApplyConfig(conf *config.Config) error {
|
||||||
// TODO: we should only stop & recreate queues which have changes,
|
// TODO: we should only stop & recreate queues which have changes,
|
||||||
// as this can be quite disruptive.
|
// as this can be quite disruptive.
|
||||||
for i, rwConf := range conf.RemoteWriteConfigs {
|
for i, rwConf := range conf.RemoteWriteConfigs {
|
||||||
c, err := NewClient(i, &clientConfig{
|
c, err := NewClient(i, &ClientConfig{
|
||||||
url: rwConf.URL,
|
URL: rwConf.URL,
|
||||||
timeout: rwConf.RemoteTimeout,
|
Timeout: rwConf.RemoteTimeout,
|
||||||
httpClientConfig: rwConf.HTTPClientConfig,
|
HTTPClientConfig: rwConf.HTTPClientConfig,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -88,11 +88,11 @@ func (s *Storage) ApplyConfig(conf *config.Config) error {
|
||||||
|
|
||||||
clients := []*Client{}
|
clients := []*Client{}
|
||||||
for i, rrConf := range conf.RemoteReadConfigs {
|
for i, rrConf := range conf.RemoteReadConfigs {
|
||||||
c, err := NewClient(i, &clientConfig{
|
c, err := NewClient(i, &ClientConfig{
|
||||||
url: rrConf.URL,
|
URL: rrConf.URL,
|
||||||
timeout: rrConf.RemoteTimeout,
|
Timeout: rrConf.RemoteTimeout,
|
||||||
httpClientConfig: rrConf.HTTPClientConfig,
|
HTTPClientConfig: rrConf.HTTPClientConfig,
|
||||||
readRecent: rrConf.ReadRecent,
|
ReadRecent: rrConf.ReadRecent,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue