output-service-tsdb/InfluxDB/InfluxWriter.cs
Kristóf Torma cca6aff3c0
All checks were successful
continuous-integration/drone/push Build is passing
added k8s config
2020-04-08 15:48:56 +02:00

33 lines
992 B
C#

using System;
using InfluxDB.Client;
using InfluxDB.Client.Api.Domain;
using OutputServiceTSDB.Models;
using OutputServiceTSDB.Utilities;
namespace OutputServiceTSDB.InfluxDB
{
public class InfluxWriter: IDisposable
{
private readonly char[] Token = EnvironmentVariableConfiguration.InfluxDBToken.ToCharArray();
private InfluxDBClient influxDBClient;
public InfluxWriter()
{
influxDBClient = InfluxDBClientFactory.Create(EnvironmentVariableConfiguration.InfluxDBHost, Token);
}
public void Write(MeasurementObject measurementObject)
{
using (var writeApi = influxDBClient.GetWriteApi())
{
writeApi.WriteMeasurement(EnvironmentVariableConfiguration.InfluxDBBucket, EnvironmentVariableConfiguration.InfluxDBOrg, WritePrecision.Ns, measurementObject);
}
}
public void Dispose()
{
influxDBClient.Dispose();
}
}
}