Skip to content

Commit

Permalink
Dial functions; import path changes for Go 1.11
Browse files Browse the repository at this point in the history
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 olivere#815).
  • Loading branch information
olivere committed Aug 26, 2018
1 parent 4ddcd1c commit 4d73bd2
Show file tree
Hide file tree
Showing 93 changed files with 409 additions and 210 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Here's the version matrix:

Elasticsearch version | Elastic version | Package URL | Remarks |
----------------------|------------------|-------------|---------|
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).
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).
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.
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.
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.
Expand All @@ -39,15 +39,22 @@ To use the required version of Elastic in your application, it is strongly
advised to use a tool like
[dep](https://github.com/golang/dep)
or
[Glide](https://glide.sh/)
to manage that dependency. Make sure to use a version such as `^6.0.0`.
[Go modules](https://github.com/golang/go/wiki/Modules)
to manage dependencies. Make sure to use a version such as `^6.0.0`.

To use Elastic, simply import:
To use Elastic with Go 1.10.2 or earlier, import:

```go
import "github.com/olivere/elastic"
```

If you're using Go 1.11 (or Go 1.10.3+) with modules support, make sure
to import Elastic like this:

```go
import "github.com/olivere/elastic/v6"
```

### Elastic 6.0

Elastic 6.0 targets Elasticsearch 6.x which was [released on 14th November 2017](https://www.elastic.co/blog/elasticsearch-6-0-0-released).
Expand Down
3 changes: 2 additions & 1 deletion aws/sign_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
"net/http/httptest"
"testing"

"github.com/olivere/elastic"
"github.com/smartystreets/go-aws-auth"

"github.com/olivere/elastic/v6"
)

func TestSigningClient(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"fmt"
"net/url"

"github.com/olivere/elastic/uritemplates"
"github.com/olivere/elastic/v6/uritemplates"
)

// BulkService allows for batching bulk requests and sending them to
Expand Down
2 changes: 1 addition & 1 deletion bulk_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func (w *bulkWorker) waitForActiveConnection(ready chan<- struct{}) {
return
}
case <-t.C:
client.healthcheck(time.Duration(3)*time.Second, true)
client.healthcheck(context.Background(), time.Duration(3)*time.Second, true)
if client.mustActiveConn() == nil {
// found an active connection
// exit and signal done to the WaitGroup
Expand Down
2 changes: 1 addition & 1 deletion cat_aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/url"
"strings"

"github.com/olivere/elastic/uritemplates"
"github.com/olivere/elastic/v6/uritemplates"
)

// CatAliasesService shows information about currently configured aliases
Expand Down
2 changes: 1 addition & 1 deletion cat_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/url"
"strings"

"github.com/olivere/elastic/uritemplates"
"github.com/olivere/elastic/v6/uritemplates"
)

// CatAllocationService provides a snapshot of how many shards are allocated
Expand Down
2 changes: 1 addition & 1 deletion cat_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/url"
"strings"

"github.com/olivere/elastic/uritemplates"
"github.com/olivere/elastic/v6/uritemplates"
)

// CatCountService provides quick access to the document count of the entire cluster,
Expand Down
2 changes: 1 addition & 1 deletion cat_indices.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/url"
"strings"

"github.com/olivere/elastic/uritemplates"
"github.com/olivere/elastic/v6/uritemplates"
)

// CatIndicesService returns the list of indices plus some additional
Expand Down
Loading

0 comments on commit 4d73bd2

Please sign in to comment.