Merge pull request #785 from mschoch/use-new-context-pkg
BREAKING API CHANGE - use stdlib context pkg
This commit is contained in:
commit
b5ce0b046f
3
index.go
3
index.go
|
@ -15,11 +15,12 @@
|
|||
package bleve
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/blevesearch/bleve/document"
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/index/store"
|
||||
"github.com/blevesearch/bleve/mapping"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// A Batch groups together multiple Index and Delete
|
||||
|
|
|
@ -15,12 +15,11 @@
|
|||
package bleve
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/blevesearch/bleve/document"
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/index/store"
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
package bleve
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/blevesearch/bleve/document"
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/index/store"
|
||||
|
@ -783,7 +782,9 @@ func TestMultiSearchTimeout(t *testing.T) {
|
|||
}}
|
||||
|
||||
// first run with absurdly long time out, should succeed
|
||||
ctx, _ = context.WithTimeout(context.Background(), 10*time.Second)
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
query := NewTermQuery("test")
|
||||
sr := NewSearchRequest(query)
|
||||
res, err := MultiSearch(ctx, sr, ei1, ei2)
|
||||
|
@ -804,7 +805,8 @@ func TestMultiSearchTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
// now run a search again with an absurdly low timeout (should timeout)
|
||||
ctx, _ = context.WithTimeout(context.Background(), 1*time.Microsecond)
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 1*time.Microsecond)
|
||||
defer cancel()
|
||||
res, err = MultiSearch(ctx, sr, ei1, ei2)
|
||||
if err != nil {
|
||||
t.Errorf("expected no error, got %v", err)
|
||||
|
@ -830,7 +832,6 @@ func TestMultiSearchTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
// now run a search again with a normal timeout, but cancel it first
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
|
||||
cancel()
|
||||
res, err = MultiSearch(ctx, sr, ei1, ei2)
|
||||
|
@ -937,7 +938,9 @@ func TestMultiSearchTimeoutPartial(t *testing.T) {
|
|||
|
||||
// ei3 is set to take >50ms, so run search with timeout less than
|
||||
// this, this should return partial results
|
||||
ctx, _ = context.WithTimeout(context.Background(), 25*time.Millisecond)
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 25*time.Millisecond)
|
||||
defer cancel()
|
||||
query := NewTermQuery("test")
|
||||
sr := NewSearchRequest(query)
|
||||
expected := &SearchResult{
|
||||
|
@ -1090,8 +1093,9 @@ func TestIndexAliasMultipleLayer(t *testing.T) {
|
|||
// ei2 and ei3 have 50ms delay
|
||||
// search across aliasTop should still get results from ei1 and ei4
|
||||
// total should still be 4
|
||||
|
||||
ctx, _ = context.WithTimeout(context.Background(), 25*time.Millisecond)
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 25*time.Millisecond)
|
||||
defer cancel()
|
||||
query := NewTermQuery("test")
|
||||
sr := NewSearchRequest(query)
|
||||
expected := &SearchResult{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package bleve
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
@ -22,8 +23,6 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/blevesearch/bleve/document"
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/index/store"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package bleve
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -28,8 +29,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/blevesearch/bleve/analysis/analyzer/keyword"
|
||||
"github.com/blevesearch/bleve/document"
|
||||
"github.com/blevesearch/bleve/index"
|
||||
|
@ -1508,7 +1507,8 @@ func TestSearchTimeout(t *testing.T) {
|
|||
}()
|
||||
|
||||
// first run a search with an absurdly long timeout (should succeeed)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
query := NewTermQuery("water")
|
||||
req := NewSearchRequest(query)
|
||||
_, err = index.SearchInContext(ctx, req)
|
||||
|
@ -1517,7 +1517,8 @@ func TestSearchTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
// now run a search again with an absurdly low timeout (should timeout)
|
||||
ctx, _ = context.WithTimeout(context.Background(), 1*time.Microsecond)
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 1*time.Microsecond)
|
||||
defer cancel()
|
||||
sq := &slowQuery{
|
||||
actual: query,
|
||||
delay: 50 * time.Millisecond, // on Windows timer resolution is 15ms
|
||||
|
@ -1529,7 +1530,7 @@ func TestSearchTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
// now run a search with a long timeout, but with a long query, and cancel it
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
||||
sq = &slowQuery{
|
||||
actual: query,
|
||||
delay: 100 * time.Millisecond, // on Windows timer resolution is 15ms
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
package search
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type Collector interface {
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type createCollector func() search.Collector
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type collectorStore interface {
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
)
|
||||
|
|
|
@ -107,15 +107,6 @@
|
|||
"branch": "master",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "golang.org/x/net/context",
|
||||
"repository": "https://go.googlesource.com/net",
|
||||
"vcs": "",
|
||||
"revision": "e45385e9b226f570b1f086bf287b25d3d4117776",
|
||||
"branch": "master",
|
||||
"path": "/context",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "golang.org/x/text/transform",
|
||||
"repository": "https://go.googlesource.com/text",
|
||||
|
|
Loading…
Reference in New Issue