hedgedhttp internals (4)
52
func waitResult(ctx context.Context, resultCh <-chan indexedResp, errorCh <-chan error,
timeout time.Duration) (indexedResp, error) {
// ...
select {
select {
case res := <-resultCh:
return res, nil
case reqErr := <-errorCh:
return indexedResp{}, reqErr
case <-ctx.Done():
return indexedResp{}, ctx.Err()
case <-timer.C:
return indexedResp{}, nil // timeout BETWEEN consecutive requests
}
}
}