Stolidedog
Stolidedog

Reputation: 41

ElasticClient Dispose

I'm new to this. I'm working with ElasticClient (.Net) and I was curious if:

  1. Is it thread safe? I assume so because it uses pooling.
  2. Should I do anything to clean up the client resources when I'm done? It does not implement IDisposable.

Thanks!

Bob

Upvotes: 4

Views: 3089

Answers (1)

gsk
gsk

Reputation: 1233

On thread safety: https://github.com/elastic/elasticsearch-net/issues/23

The ElasticClient holds a single IConnection responsible for doing async and sync http calls. The IConnection does not reuse httprequests and uses thread local state for data thats being passed around during the stages of the request. It should thus be thread safe.

On disposing: https://github.com/elastic/elasticsearch-net/issues/101

ElasticClient is almost stateless except for a static CLR type info cache that is threadsafe so you can even use one client over threads. Disposing is also handled by Nest and ElasticClient only exposes POCO's.

Upvotes: 3

Related Questions