Kristóf Torma
cca6aff3c0
All checks were successful
continuous-integration/drone/push Build is passing
33 lines
992 B
C#
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();
|
|
}
|
|
}
|
|
}
|