mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 23:42:32 +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.
|
||||
func contextDone(ctx context.Context, env string) error {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return contextErr(ctx.Err(), env)
|
||||
default:
|
||||
return nil
|
||||
if err := ctx.Err(); err != nil {
|
||||
return contextErr(err, env)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func contextErr(err error, env string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user