Skip to content

Commit

Permalink
Fix/unify context-based remote storage timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusv committed Mar 20, 2017
1 parent 815762a commit 9b33cfc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion storage/remote/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func (c *Client) Store(samples model.Samples) error {
}
httpReq.Header.Add("Content-Encoding", "snappy")

ctx, _ := context.WithTimeout(context.Background(), c.timeout)
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
defer cancel()

httpResp, err := ctxhttp.Do(ctx, c.client, httpReq)
if err != nil {
return err
Expand Down Expand Up @@ -144,6 +146,10 @@ func (c *Client) Read(ctx context.Context, from, through model.Time, matchers me
if err != nil {
return nil, fmt.Errorf("unable to create request: %v", err)
}

ctx, cancel := context.WithTimeout(ctx, c.timeout)
defer cancel()

httpResp, err := ctxhttp.Do(ctx, c.client, httpReq)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
Expand Down

0 comments on commit 9b33cfc

Please sign in to comment.