mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 16:02:28 +00:00
Replace select with simpler error check
The documentation for Context states that this is just as good: // If Done is not yet closed, Err returns nil. // If Done is closed, Err returns a non-nil error Signed-off-by: Bryan Boreham <bryan@weave.works>
This commit is contained in:
parent
cc75c27580
commit
e4a37d0986
@ -182,12 +182,10 @@ func (q *query) Exec(ctx context.Context) *Result {
|
|||||||
|
|
||||||
// contextDone returns an error if the context was canceled or timed out.
|
// contextDone returns an error if the context was canceled or timed out.
|
||||||
func contextDone(ctx context.Context, env string) error {
|
func contextDone(ctx context.Context, env string) error {
|
||||||
select {
|
if err := ctx.Err(); err != nil {
|
||||||
case <-ctx.Done():
|
return contextErr(err, env)
|
||||||
return contextErr(ctx.Err(), env)
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func contextErr(err error, env string) error {
|
func contextErr(err error, env string) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user