InfluxCommunity / influxdb3-csharp

The C# .NET Client that provides a simple and convenient way to interact with InfluxDB 3.
https://InfluxCommunity.github.io/influxdb3-csharp/
MIT License
24 stars 6 forks source link

Specify whether InfluxDBClient can be reused #43

Closed ben-propflo closed 1 year ago

ben-propflo commented 1 year ago

Currently I'm creating a new InfluxDBClient for each query/write but it may be beneficial to re-use the same instance. HttpClient can reuse the connection for example. I'm not so sure reusing the instance will work as intended given the usage of HttpClient doesn't appear to follow the current guidelines. The easiest solution would be to implement IHttpClientFactory I reckon. It'll be nice to specify in the docs if reuse is supported, and perhaps look into making it reusable if that currently isn't the case.

bednar commented 1 year ago

Hi @ben-propflo,

Thank you for using our client.

Our intention is for the client to be used as a singleton - a long-livedclient. You can find the client initialization here: https://github.com/bonitoo-io/influxdb3-csharp/blob/75cc2f7c88fc8c1ec039d83a1ef6be474469a55f/Client/InfluxDBClient.cs#L315.

Best

ben-propflo commented 1 year ago

Great thanks @bednar. I was going to raise a PR to fix the bit about respecting DNS changes but it appears netstandard doesn't expose the property required. This sums it up nicely https://github.com/dotnet/aspnetcore/issues/28385#issuecomment-853766480