public void WithClient() { var httpClient = new HttpClient(new MockHttpMessageHandler()) { BaseAddress = new Uri("http://localhost:8086") }; var influxHttpClient = new InfluxDBHttpClient(httpClient); using (var client = InfluxDBClient.Create(influxHttpClient, "foo", "autogen", _ => { }, 8192, 8192 * 32, null)) { foreach (var metric in Metrics) { client.TryRequest(new WriteRequest(Formatter, metric)); } } }
public void WithChannel() { var httpClient = new HttpClient(new MockHttpMessageHandler()) { BaseAddress = new Uri("http://localhost:8086") }; var influxHttpClient = new InfluxDBHttpClient(httpClient); using (var channel = InfluxDBChannel.Create(influxHttpClient, "foo", "autogen", _ => { })) { int size = 256; foreach (var metric in Metrics) { var buffer = channel.GetBuffer(size); int bytesWritten; while (!Formatter.TryWrite(buffer.Span, metric, null, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), out bytesWritten)) { size = buffer.Grow(); } channel.TryAdd(buffer, bytesWritten); } } }