influxdb-client-csharp icon indicating copy to clipboard operation
influxdb-client-csharp copied to clipboard

Initialize C# client without `InfluxDBClientFactory`

Open ivankudibal opened this issue 2 years ago • 0 comments

In the C# world is not common to use builder patter for initialization:

var options = new InfluxDBClientOptions.Builder()
    .Url("http://localhost:8086")
    .AuthenticateToken("my-token")
    .TimeOut(TimeSpan.FromSeconds(30))
    .Build();

using var client = InfluxDBClientFactory.Create(options);

instead we should use object initializer:

var settings = new InfluxDBClientOptions
{
    Url = "http://localhost:8086",
    AuthenticateToken = "my-token",
    TimeOut = TimeSpan.FromSeconds(30),
};

using var client = new InfluxDBClient(settings);

TODO:

  1. It should be backward compatible
  2. Use initializer pattern also for WriteOptions, FluxConnectionOptions
  3. Refactor examples to use initializer instead of factory
  4. Refactor documentation to use initializer instead of factory
  5. Update InfluxDB UI to use initializer: image Sources: https://github.com/influxdata/ui/tree/master/src/writeData/clients/CSharp

ivankudibal avatar Oct 10 '22 13:10 ivankudibal