Skip to content

Commit 4d73bd2

Browse files
committed
Dial functions; import path changes for Go 1.11
This commit prepares the 6.2.0 release. It comes with the following set of changes. First, we fix the import path to work correctly with Go modules introduced in Go 1.11. Notice that this change requires using Go 1.10.4+ or later. If you're on an earlier version of Go, consider updating or use `6.1.x` until you can. Second, we add a set of `Dial` functions, i.e. `Dial`, `DialContext`, and `DialWithConfig` to better align with the standard library in terms of keeping a long-running TCP connection with a resource, in our case: Elasticsearch. In v6, the `Dial` functions will be kept as an alias to `NewClient`. This might change in v7. Also, the `DialContext` and `DialWithConfig` functions allow to pass a context to be able to cancel connecting early. Notice that cancelation can happen both due to the context being canceled, or because of a configured timeout, e.g. via `SetHealthcheckTimeoutStartup`, whichever timeout comes first (close #815).
1 parent 4ddcd1c commit 4d73bd2

File tree

93 files changed

+409
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+409
-210
lines changed

README.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Here's the version matrix:
2424

2525
Elasticsearch version | Elastic version | Package URL | Remarks |
2626
----------------------|------------------|-------------|---------|
27-
6.x                   | 6.0             | [`github.com/olivere/elastic`](https://github.com/olivere/elastic) ([source](https://github.com/olivere/elastic/tree/release-branch.v6) [doc](http://godoc.org/github.com/olivere/elastic)) | Use a dependency manager (see below).
27+
6.x                   | 6.0             | [`github.com/olivere/elastic/v6`](https://github.com/olivere/elastic) ([source](https://github.com/olivere/elastic/tree/release-branch.v6) [doc](http://godoc.org/github.com/olivere/elastic)) | Use a dependency manager (see below).
2828
5.x | 5.0 | [`gopkg.in/olivere/elastic.v5`](https://gopkg.in/olivere/elastic.v5) ([source](https://github.com/olivere/elastic/tree/release-branch.v5) [doc](http://godoc.org/gopkg.in/olivere/elastic.v5)) | Actively maintained.
2929
2.x | 3.0 | [`gopkg.in/olivere/elastic.v3`](https://gopkg.in/olivere/elastic.v3) ([source](https://github.com/olivere/elastic/tree/release-branch.v3) [doc](http://godoc.org/gopkg.in/olivere/elastic.v3)) | Deprecated. Please update.
3030
1.x | 2.0 | [`gopkg.in/olivere/elastic.v2`](https://gopkg.in/olivere/elastic.v2) ([source](https://github.com/olivere/elastic/tree/release-branch.v2) [doc](http://godoc.org/gopkg.in/olivere/elastic.v2)) | Deprecated. Please update.
@@ -39,15 +39,22 @@ To use the required version of Elastic in your application, it is strongly
3939
advised to use a tool like
4040
[dep](https://github.com/golang/dep)
4141
or
42-
[Glide](https://glide.sh/)
43-
to manage that dependency. Make sure to use a version such as `^6.0.0`.
42+
[Go modules](https://github.com/golang/go/wiki/Modules)
43+
to manage dependencies. Make sure to use a version such as `^6.0.0`.
4444

45-
To use Elastic, simply import:
45+
To use Elastic with Go 1.10.2 or earlier, import:
4646

4747
```go
4848
import "github.com/olivere/elastic"
4949
```
5050

51+
If you're using Go 1.11 (or Go 1.10.3+) with modules support, make sure
52+
to import Elastic like this:
53+
54+
```go
55+
import "github.com/olivere/elastic/v6"
56+
```
57+
5158
### Elastic 6.0
5259

5360
Elastic 6.0 targets Elasticsearch 6.x which was [released on 14th November 2017](https://www.elastic.co/blog/elasticsearch-6-0-0-released).

aws/sign_v4_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111
"net/http/httptest"
1212
"testing"
1313

14-
"github.com/olivere/elastic"
1514
"github.com/smartystreets/go-aws-auth"
15+
16+
"github.com/olivere/elastic/v6"
1617
)
1718

1819
func TestSigningClient(t *testing.T) {

bulk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"fmt"
1212
"net/url"
1313

14-
"github.com/olivere/elastic/uritemplates"
14+
"github.com/olivere/elastic/v6/uritemplates"
1515
)
1616

1717
// BulkService allows for batching bulk requests and sending them to

bulk_processor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func (w *bulkWorker) waitForActiveConnection(ready chan<- struct{}) {
574574
return
575575
}
576576
case <-t.C:
577-
client.healthcheck(time.Duration(3)*time.Second, true)
577+
client.healthcheck(context.Background(), time.Duration(3)*time.Second, true)
578578
if client.mustActiveConn() == nil {
579579
// found an active connection
580580
// exit and signal done to the WaitGroup

cat_aliases.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"github.com/olivere/elastic/v6/uritemplates"
1414
)
1515

1616
// CatAliasesService shows information about currently configured aliases

cat_allocation.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"github.com/olivere/elastic/v6/uritemplates"
1414
)
1515

1616
// CatAllocationService provides a snapshot of how many shards are allocated

cat_count.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"github.com/olivere/elastic/v6/uritemplates"
1414
)
1515

1616
// CatCountService provides quick access to the document count of the entire cluster,

cat_indices.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"github.com/olivere/elastic/v6/uritemplates"
1414
)
1515

1616
// CatIndicesService returns the list of indices plus some additional

0 commit comments

Comments
 (0)