Skip to content

Commit

Permalink
README: Add note about persistent HTTP connections
Browse files Browse the repository at this point in the history
Also update the example and add esutil.BulkIndexer to the list of helpers.

(cherry picked from commit bbd6b17)
  • Loading branch information
karmi committed May 15, 2020
1 parent 3c036aa commit db2bcf5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -98,6 +98,7 @@ if err != nil {
log.Fatalf("Error getting response: %s", err)
}

defer res.Body.Close()
log.Println(res)

// [200 OK] {
Expand All @@ -106,6 +107,8 @@ log.Println(res)
// ...
```

> NOTE: It is _critical_ to both close the response body _and_ to consume it, in order to re-use persistent TCP connections in the default HTTP transport. If you're not interested in the response body, call `io.Copy(ioutil.Discard, res.Body)`.
When you export the `ELASTICSEARCH_URL` environment variable,
it will be used to set the cluster endpoint(s). Separate multiple adresses by a comma.

Expand Down Expand Up @@ -353,8 +356,7 @@ The `estransport` package handles the transfer of data to and from Elasticsearch

## Helpers

The `esutil` package provides convenience helpers for working with the client. At the moment, it provides the
`esutil.JSONReader()` helper function.
The `esutil` package provides convenience helpers for working with the client. At the moment, it provides the `esutil.JSONReader()` and the `esutil.BulkIndexer` helpers.

<!-- ----------------------------------------------------------------------------------------------- -->

Expand Down

0 comments on commit db2bcf5

Please sign in to comment.