Skip to content

Commit

Permalink
Merge pull request #66 from nblumhardt/modernize-again
Browse files Browse the repository at this point in the history
Port to `System.Threading.Channels`
  • Loading branch information
nblumhardt authored Jan 1, 2024
2 parents 2015487 + 83f9133 commit 6455380
Show file tree
Hide file tree
Showing 34 changed files with 457 additions and 1,444 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,4 @@ BenchmarkDotNet.Artifacts/
.idea
*.orig

.DS_Store/
15 changes: 2 additions & 13 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ foreach ($src in Get-ChildItem src/*) {
} else {
& dotnet pack -c Release --no-build -o ..\..\artifacts
}
if($LASTEXITCODE -ne 0) { exit 1 }
if($LASTEXITCODE -ne 0) { throw "Failed" }

Pop-Location
}
Expand All @@ -44,18 +44,7 @@ foreach ($test in Get-ChildItem test/*.Tests) {
Write-Output "build: Testing project in $test"

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 3 }

Pop-Location
}

foreach ($test in Get-ChildItem test/*.PerformanceTests) {
Push-Location $test

Write-Output "build: Building performance test project in $test"

& dotnet build -c Release
if($LASTEXITCODE -ne 0) { exit 2 }
if($LASTEXITCODE -ne 0) { throw "Failed" }

Pop-Location
}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.300",
"version": "8.0.100",
"allowPrerelease": false,
"rollForward": "latestFeature"
}
Expand Down
14 changes: 7 additions & 7 deletions serilog-sinks-periodicbatching.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.PeriodicBatch
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.PeriodicBatching.Tests", "test\Serilog.Sinks.PeriodicBatching.Tests\Serilog.Sinks.PeriodicBatching.Tests.csproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.PeriodicBatching.PerformanceTests", "test\Serilog.Sinks.PeriodicBatching.PerformanceTests\Serilog.Sinks.PeriodicBatching.PerformanceTests.csproj", "{80B760D1-3862-49AD-9D72-23608550C318}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{E49CF29C-7646-4E9E-82C6-BF81A76A116F}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Expand All @@ -32,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{E49CF29C-764
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestHarness", "test\TestHarness\TestHarness.csproj", "{20A1F97F-3EEB-4D9B-981C-20818228FAC9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -46,17 +46,17 @@ Global
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.Build.0 = Release|Any CPU
{80B760D1-3862-49AD-9D72-23608550C318}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80B760D1-3862-49AD-9D72-23608550C318}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80B760D1-3862-49AD-9D72-23608550C318}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80B760D1-3862-49AD-9D72-23608550C318}.Release|Any CPU.Build.0 = Release|Any CPU
{20A1F97F-3EEB-4D9B-981C-20818228FAC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20A1F97F-3EEB-4D9B-981C-20818228FAC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20A1F97F-3EEB-4D9B-981C-20818228FAC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20A1F97F-3EEB-4D9B-981C-20818228FAC9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{324C2F52-D9F7-4844-9BC4-9906E228D380} = {037440DE-440B-4129-9F7A-09B42D00397E}
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {F6E07A13-B9D3-4019-B25A-DE1F6C17E108}
{80B760D1-3862-49AD-9D72-23608550C318} = {F6E07A13-B9D3-4019-B25A-DE1F6C17E108}
{20A1F97F-3EEB-4D9B-981C-20818228FAC9} = {F6E07A13-B9D3-4019-B25A-DE1F6C17E108}
EndGlobalSection
EndGlobal
2 changes: 0 additions & 2 deletions src/Serilog.Sinks.PeriodicBatching/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("3.0.0.0")]

[assembly: CLSCompliant(true)]

[assembly: InternalsVisibleTo("Serilog.Sinks.PeriodicBatching.Tests, PublicKey=" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

<PropertyGroup>
<Description>Buffer batches of log events to be flushed asynchronously.</Description>
<VersionPrefix>3.1.1</VersionPrefix>
<VersionPrefix>4.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>net45;netstandard1.1;netstandard1.2;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net462</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;net6.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RootNamespace>Serilog</RootNamespace>
<PackageTags>serilog;batching;timer</PackageTags>
Expand All @@ -13,32 +14,22 @@
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-periodicbatching</PackageProjectUrl>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-periodicbatching</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
<DefineConstants>$(DefineConstants);FEATURE_THREADING_TIMER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);FEATURE_THREADING_TIMER;FEATURE_EXECUTION_CONTEXT</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<DefineConstants>$(DefineConstants);FEATURE_THREADING_TIMER;FEATURE_EXECUTION_CONTEXT;FEATURE_ASYNCDISPOSABLE</DefineConstants>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<DefineConstants>$(DefineConstants);FEATURE_ASYNCDISPOSABLE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
</ItemGroup>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ namespace Serilog.Sinks.PeriodicBatching;
/// also overproduction (the second, queue-dropping response). In combination these should provide a
/// reasonable delivery effort but ultimately protect the sender from memory exhaustion.
/// </summary>
/// <remarks>
/// Currently used only by <see cref="PeriodicBatchingSink"/>, but may
/// provide the basis for a "smart" exponential backoff timer. There are other factors to consider
/// including the desire to send batches "when full" rather than continuing to buffer, and so-on.
/// </remarks>
class BatchedConnectionStatus
class FailureAwareBatchScheduler
{
static readonly TimeSpan MinimumBackoffPeriod = TimeSpan.FromSeconds(5);
static readonly TimeSpan MaximumBackoffInterval = TimeSpan.FromMinutes(10);
Expand All @@ -42,9 +37,10 @@ class BatchedConnectionStatus

int _failuresSinceSuccessfulBatch;

public BatchedConnectionStatus(TimeSpan period)
public FailureAwareBatchScheduler(TimeSpan period)
{
if (period < TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(period), "The batching period must be a positive timespan");
if (period < TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(period), "The batching period must be a positive timespan.");

_period = period;
}
Expand Down
Loading

0 comments on commit 6455380

Please sign in to comment.