Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sample/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<TargetFrameworks>net472</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<PackageId>Sample</PackageId>
<ApplicationIcon />
Expand Down
2 changes: 1 addition & 1 deletion sample/Sample-UDP-Support/Sample-UDP-Support.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>Sample_UDP_Support</RootNamespace>
<AssemblyName>Sample-UDP-Support</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<PackageId>Sample</PackageId>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/InfluxDB.Collector/InfluxDB.Collector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>InfluxDB.Collector</AssemblyName>
<VersionPrefix>1.1.1</VersionPrefix>
<VersionPrefix>1.2.0</VersionPrefix>
<PackageId>InfluxDB.Collector</PackageId>
<PackageTags>influxdb</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/influxdata/influxdb-csharp/master/asset/influxdata.jpg</PackageIconUrl>
Expand Down
5 changes: 3 additions & 2 deletions src/InfluxDB.LineProtocol/Client/ILineProtocolClient.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Threading;
using System;
using System.Threading;
using System.Threading.Tasks;
using InfluxDB.LineProtocol.Payload;

namespace InfluxDB.LineProtocol.Client
{
public interface ILineProtocolClient
public interface ILineProtocolClient : IDisposable
{
Task<LineProtocolWriteResult> SendAsync(
LineProtocolWriter lineProtocolWriter,
Expand Down
5 changes: 5 additions & 0 deletions src/InfluxDB.LineProtocol/Client/LineProtocolClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ protected override async Task<LineProtocolWriteResult> OnSendAsync(

return new LineProtocolWriteResult(false, $"{response.StatusCode} {response.ReasonPhrase} {body}");
}

protected override void DisposeOfManagedResources()
{
_httpClient.Dispose();
}
}
}
20 changes: 20 additions & 0 deletions src/InfluxDB.LineProtocol/Client/LineProtocolClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace InfluxDB.LineProtocol.Client
public abstract class LineProtocolClientBase : ILineProtocolClient
{
protected readonly string _database, _username, _password;
private volatile int _isDisposed;

protected LineProtocolClientBase(Uri serverBaseAddress, string database, string username, string password)
{
Expand Down Expand Up @@ -41,9 +42,28 @@ protected LineProtocolClientBase(Uri serverBaseAddress, string database, string
return OnSendAsync(lineProtocolWriter.ToString(), lineProtocolWriter.Precision, cancellationToken);
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected abstract Task<LineProtocolWriteResult> OnSendAsync(
string payload,
Precision precision,
CancellationToken cancellationToken = default(CancellationToken));

protected void Dispose(bool disposing)
{
if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
{
if (disposing)
{
DisposeOfManagedResources();
}
}
}

protected abstract void DisposeOfManagedResources();
}
}
5 changes: 5 additions & 0 deletions src/InfluxDB.LineProtocol/Client/LineProtocolUdpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@ protected override async Task<LineProtocolWriteResult> OnSendAsync(
int len = await _udpClient.SendAsync(buffer, buffer.Length, _udpHostName, _udpPort);
return new LineProtocolWriteResult(len == buffer.Length, null);
}

protected override void DisposeOfManagedResources()
{
_udpClient.Dispose();
}
}
}
4 changes: 2 additions & 2 deletions src/InfluxDB.LineProtocol/InfluxDB.LineProtocol.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>A .NET library for efficiently sending time series to InfluxDB</Description>
<Authors>influxdb-csharp Contributors</Authors>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<VersionPrefix>1.1.1</VersionPrefix>
<VersionPrefix>1.2.0</VersionPrefix>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>InfluxDB.LineProtocol</AssemblyName>
<PackageId>InfluxDB.LineProtocol</PackageId>
Expand Down
4 changes: 2 additions & 2 deletions test/Consoles/InfluxDb.UdpSupport.ConsoleTest/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>InfluxDb.UdpSupport.ConsoleTest</RootNamespace>
<AssemblyName>InfluxDb.UdpSupport.ConsoleTest</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<AssemblyName>InfluxDB.LineProtocol.Tests</AssemblyName>
<PackageId>InfluxDB.LineProtocol.Tests</PackageId>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
Expand Down