elasticsearch.Client should consider a Close function as its elastictransport.Client does a couple things, which at least for unit tests may be best to stop explicitly. We may also want to accept a context on New for similar reasons.
Starts the goroutine client.DiscoverNodes: This may want to be cancelable, e.g. passing a context to the New function. Agree this is not typical, but personally I pass ctx into New functions that perform I/O.
I didn't mention the edge case of http transport, that we have an opportunity to CloseIdleConnections, as I think above are more important to rule in or out.
elasticsearch.Client
should consider aClose
function as itselastictransport.Client
does a couple things, which at least for unit tests may be best to stop explicitly. We may also want to accept a context onNew
for similar reasons.Starts the goroutine
client.DiscoverNodes
: This may want to be cancelable, e.g. passing a context to theNew
function. Agree this is not typical, but personally I passctx
intoNew
functions that perform I/O.Via elastic-transport-go, starts a self-scheduling function for discovery: On
Close
, this should be stopped explicitly somehow, or documented why that's not required.I didn't mention the edge case of http transport, that we have an opportunity to CloseIdleConnections, as I think above are more important to rule in or out.