Skip to content

Commit db2bcf5

Browse files
committed
README: Add note about persistent HTTP connections
Also update the example and add esutil.BulkIndexer to the list of helpers. (cherry picked from commit bbd6b17)
1 parent 3c036aa commit db2bcf5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ if err != nil {
9898
log.Fatalf("Error getting response: %s", err)
9999
}
100100

101+
defer res.Body.Close()
101102
log.Println(res)
102103

103104
// [200 OK] {
@@ -106,6 +107,8 @@ log.Println(res)
106107
// ...
107108
```
108109

110+
> 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)`.
111+
109112
When you export the `ELASTICSEARCH_URL` environment variable,
110113
it will be used to set the cluster endpoint(s). Separate multiple adresses by a comma.
111114

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

354357
## Helpers
355358

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

359361
<!-- ----------------------------------------------------------------------------------------------- -->
360362

0 commit comments

Comments
 (0)